Esempio n. 1
0
if 3 != len(sys.argv):
    print("Usage: set_sensor_config.py configFile sensorExec")
    sys.exit()

configFile = open(sys.argv[1], 'r').read()
sensorFile = open(sys.argv[2], 'r')
sensor = sensorFile.read()
sensorFile.close()

prevPath = os.getcwd()
os.chdir(os.path.join(os.path.dirname(__file__), '..', '..'))

r = rpcm(isDebug=True)
rpcm_environment = {
    '_': Symbols(),
    'rList': rList,
    'rSequence': rSequence,
    'AgentId': AgentId,
    'tarGzOf': tarGzOf
}

conf = eval(configFile.replace('\n', ''), rpcm_environment)

conf = obfuscate(r.serialise(conf), OBFUSCATION_KEY)

magic = "\xFA\x57\xF0\x0D" + ("\x00" * (len(conf) - 4))

os.chdir(prevPath)

if magic in sensor:
Esempio n. 2
0
    return val

if 3 != len( sys.argv ):
    print( "Usage: set_sensor_config.py configFile sensorExec" )
    sys.exit()

configFile = open( sys.argv[ 1 ], 'r' ).read()
sensorFile = open( sys.argv[ 2 ], 'r' )
sensor = sensorFile.read()
sensorFile.close()

prevPath = os.getcwd()
os.chdir( os.path.join( os.path.dirname( __file__ ), '..', '..' ) )

r = rpcm( isDebug = True )
rpcm_environment = { '_' : Symbols(), 'rList' : rList, 'rSequence' : rSequence, 'AgentId' : AgentId, 'tarGzOf' : tarGzOf }

conf = eval( configFile.replace( '\n', '' ), rpcm_environment )

conf = obfuscate( r.serialise( conf ), OBFUSCATION_KEY )

magic = "\xFA\x57\xF0\x0D" + ( "\x00" * ( len( conf ) - 4 ) )

os.chdir( prevPath )

if magic in sensor:
    sensor = sensor.replace( magic, conf )
    sensorFile = open( sys.argv[ 2 ], 'w' )
    sensorFile.write( sensor )
    sensorFile.close()
    print( "Sensor patched." )
Esempio n. 3
0
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
from hcp.utils.rpcm import *
from hcp.Symbols import Symbols
import uuid
import base64

_ = Symbols()


def urlPort(val):
    res = val.split(':')
    res = (res[0], int(res[1]))
    return res


parser = argparse.ArgumentParser(description='Create Bootstrap')
parser.add_argument('--root_pub_key',
                    type=argparse.FileType('r'),
                    required=True,
                    help='root public key to trust in DER format',
                    dest='root_pub_key')
parser.add_argument('--primary',
Esempio n. 4
0
if 3 > len( sys.argv ):
    print( "Usage: set_sensor_config.py configFile sensorExec [installer-uuid]" )
    sys.exit( -1 )

configFile = open( sys.argv[ 1 ], 'r' ).read()
sensorFile = open( sys.argv[ 2 ], 'r' )
installerUuid = uuid.UUID( sys.argv[ 3 ] ) if len( sys.argv ) >= 4 else uuid.UUID( '00000000-0000-0000-0000-000000000001' )
sensor = sensorFile.read()
sensorFile.close()

prevPath = os.getcwd()
os.chdir( os.path.join( os.path.dirname( __file__ ), '..', '..' ) )

r = rpcm( isDebug = True )
rpcm_environment = { '_' : Symbols(), 'rList' : rList, 'rSequence' : rSequence, 'AgentId' : AgentId, 'tarGzOf' : tarGzOf, 'INSTALLER_UUID' : installerUuid, 'uuid' : uuid }

conf = eval( configFile.replace( '\n', '' ), rpcm_environment )

conf = obfuscate( r.serialise( conf ), OBFUSCATION_KEY )

magic = "\xFA\x57\xF0\x0D" + ( "\x00" * ( len( conf ) - 4 ) )

os.chdir( prevPath )

if magic in sensor:
    sensor = sensor.replace( magic, conf )
    sensorFile = open( sys.argv[ 2 ], 'w' )
    sensorFile.write( sensor )
    sensorFile.close()
    print( "Sensor patched." )
Esempio n. 5
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from gevent import monkey
monkey.patch_all()
import gevent.pool

from VirtualSensor import VirtualSensor
from hcp.utils.hcp_helpers import AgentId
from hcp.utils.rpcm import rpcm
from hcp.utils.rpcm import rList
from hcp.utils.rpcm import rSequence
from hcp.Symbols import Symbols
Symbols = Symbols()
import time
import signal
import msgpack
import base64
import sys
import argparse
import random
import string
import uuid
import hashlib

parser = argparse.ArgumentParser(prog='Simulator')
parser.add_argument('cloud', type=str, help='where to reach the cloud')
parser.add_argument('oid',
                    type=str,
Esempio n. 6
0
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
from hcp.Symbols import Symbols
from hcp.hcp_helpers import HbsCollectorId

tags = Symbols()


def validNotification(s):
    if not hasattr(tags.notification, s):
        raise argparse.ArgumentError('value is not a valid notification tag')
    return s


def int16(s):
    return int(s, 16)


parser = argparse.ArgumentParser()
parser.add_argument('-x',
                    '--exfil',