示例#1
0
import adminPacket
import datetime,time


if __name__ == '__main__': 
    host = '192.168.91.158'
    BUFSIZE = 1024 
    port = 5530
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    except socket.error, msg:
        print '---line 110---Failed to create socket.Error code: '+ str(msg[0]) + ', Error message: ' + msg[1]
        sys.exit()
    print '---line 112--- Socket create'
    s.connect((host, port))    
    admin_packet=adminPacket.AdminPacket()
    admin_packet.admin(s)
    ack_key=admin_packet.get_sess_key()
    ack_key_id=admin_packet.get_sess_key_id()
    print '******ack_key',ack_key
    #time.sleep(300)
    #generate part   
    req_packet=reqPacket.ReqPacket()
    req_packet.set_sess_key(ack_key)
    req_packet.set_sess_key_id(ack_key_id)
    req_packet.set_version(1)
    req_packet.set_encry_alg(1)
    req_packet.set_msg_typ(125)
    #set req packet message
    req_user_name='client_qh001'
    req_reqid=205
示例#2
0
        


#修改应用密钥报文,根据传入的ip,username,user_typ,key_id,接入host,并修改应用密钥
def ModAkmKey(host_ip,user_name,user_typ,key_id): 
    host = host_ip
    BUFSIZE = 4096 
    port = 5530
    try: 
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    except socket.error, msg:
        print '---line 110---Failed to create socket.Error code: '+ str(msg[0]) + ', Error message: ' + msg[1]
        sys.exit()
    print '---line 112--- Socket create'
    s.connect((host, port))    
    admin_packet=adminPacket.AdminPacket(user_name,user_typ,key_id)
    admin_packet.admin(s)
    ack_key=admin_packet.get_sess_key()
    ack_key_id=admin_packet.get_sess_key_id()
    print '******ack_key',ack_key
    #time.sleep(60)
    #generate part   
    rc_packet=akmReqPacket.ModReqPacket()
    rc_packet.set_sess_key(ack_key)
    rc_packet.set_sess_key_id(ack_key_id)
    rc_packet.set_version(1)
    rc_packet.set_encry_alg(1)
    
    #set req packet message   
    rc_msg_typ=123
    rc_reqid=60
示例#3
0
    UserID = 1100100
    UserTyp = 0
    #KeyID=[01,01,01,01,01,01,01,01,01,01,01,01,01,01,00,03]
    KeyID = '61626364653130300000000000000000'

    print 'KeyID', KeyID

    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    except socket.error, msg:
        print '---line 110---Failed to create socket.Error code: ' + str(
            msg[0]) + ', Error message: ' + msg[1]
        sys.exit()
    print '---line 112--- Socket create'
    s.connect((host, port))
    admin_packet = adminPacket.AdminPacket(UserName, UserTyp, KeyID)
    admin_packet.admin(s)
    ack_key = admin_packet.get_sess_key()
    ack_key_id = admin_packet.get_sess_key_id()
    print '******ack_key', ack_key
    time.sleep(60)
    #generate part


def gen_sys_key(s, local_user_id, remote_user_id, ack_key, ack_key_id):

    UserID = local_user_id
    hostID = remote_user_id
    gen_packet = genPacket.GenPacket()
    gen_packet.set_version(1)
    gen_packet.set_encry_alg(1)