def main(): cprint('+-------------------------------+', 'yellow') cprint('| |', 'yellow') cprint('| Welcome, ZJUer! |', 'yellow') cprint('| |', 'yellow') cprint('| Auto Login ZJUWLAN (v1) |', 'yellow') cprint('| create by ChanLo |', 'yellow') cprint('| |', 'yellow') cprint('+-------------------------------+\n', 'yellow') UPSave = DataSave.UPSave() if not if_use_existing_account(use_account): username, password = get_user_UP() UPSave.delete_DB(name_DB) UPSave.create_DB(name_DB) UPSave.insert_to_DB(name_DB, username, password) else: username, password = UPSave.select_DB(name_DB, aim_id) data = { 'action': 'login', 'username': username, 'password': password, 'ac_id': '3', 'user_ip': '', 'nas_ip': '', 'user_mac': '', 'save_me': '1', 'ajax': '1' } data = urllib.parse.urlencode(data) try: req = Request('https://net.zju.edu.cn/srun_portal_pc.php?url=&ac_id=3') with urlopen(req, data.encode('utf-8'), timeout=10) as response: content = response.read() cprint('Checking network status...\n', 'green') sleep(1) detection = Detection.Detection() if detection.is_connected(): cprint('Login Successfully!', 'red') else: cprint('Connection fail.', 'green') except URLError as e: if hasattr(e, 'reason'): info = '[ERROR] Failed to reach the server.\Reason: ' + str( e.reason) elif hasattr(e, 'code'): info = '[ERROR] The server couldn\'t fullfill the request.\nError code: ' + str( e.reason) else: info = '[ERROR] Unknown URLError' print(info) except: import traceback print('Generic exception: ' + traceback.format_exc())
def process_image(img): img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR) mydetect = Detection.Detection(img, picklefile) mydetect.multiple_scale_window(scales, y_start_stops) #print(Record.history_track) if len(Record.history_track) > 0: last_threshold = mydetect.process_heatmap(np.int(np.min(np.array(Record.history_track)))) else: last_threshold = mydetect.process_heatmap(2) if last_threshold > 0: Record.history_track.append(last_threshold) else: Record.history_track = [] if len(Record.history_track) > Record.cache_size: Record.history_track = Record.history_track[1:] return mydetect.draw_label_box()
import Detection import sys import rospy if __name__ == '__main__': try: print("----------------------------------------------------------") print("Welcome to the MoveIt MoveGroup Python Interface Nursing") print("----------------------------------------------------------") print("Press Ctrl-D to exit at any time") print("") input("============ Press `Enter` to begin the process ...") tutorial = MoveGroupPythonInterfaceNursing() input("============ Go to the door knob ...") node = Detection(0.9, 1, 10) #patrol_test.move(4.61152219772, -5.15782785416, -0.37051665948, 0.928825820619) input("============ Standby position ...") tutorial.go_to_joint_state() input("============ Stretch arm ...") input("gripper_hold") tutorial.gripper_hold() input("gripper_release") tutorial.gripper_release() input( "============ Press `Enter` to execute a movement using a pose goal ..."
default='11:39:0') args = parser.parse_args() set_time = [args.morning, args.afternoon, args.evening] name = '' while True: files= os.listdir('input') preProcess = PreProcess() index_new = preProcess.nameImage() d = datetime.now() cur_time = str(d.hour) +':'+ str(d.minute) + ':'+ str(d.second) #capture for i in range(len(set_time)): if cur_time == set_time[i]: preProcess.captureImage() #resize & name if len(files)>0: for file in files: sleep(3) test = PreProcess(file=file, name=index_new) test.preImages() index_new = index_new +1 if index_new > 0: detect = Detection() detect.analyzing()
def sniffSlaac(self, buf, getInterface): eth = EthDecoder().decode(buf) ethChild = eth.child() ethChild2 = ethChild.child() try: if ethChild2.get_ip_protocol_number() == 58: destination_MAC_address = eth.get_ether_dhost() source_MAC_address = eth.get_ether_shost() source_MAC_address_final = "" destination_MAC_address_final = "" override_flag = False router_flag = False router_lifetime = "False" for x in range(6): temp_decimal = source_MAC_address[x] temp_hex = hex(temp_decimal) source_MAC_address_final = source_MAC_address_final + temp_hex[ 2:] + ":" temp_decimal = destination_MAC_address[x] temp_hex = hex(temp_decimal) destination_MAC_address_final = destination_MAC_address_final + temp_hex[ 2:] + ":" source_MAC_address_final = source_MAC_address_final[:-1].zfill( 2) destination_MAC_address_final = destination_MAC_address_final[: -1] target_link_layer_address = "" packetData = (ethChild2.get_originating_packet_data()) packetHex = [] payloadHex = [] for data in packetData: packetHex.append(hex(data)) source_link_layer_address = "" target_address = "" ip_source_address = ethChild.get_source_address() ip_destination_address = ethChild.get_destination_address() ndp_message_number = ethChild2.get_type() contains_source, offset = self.check_ipv6_options(packetHex) if str(ndp_message_number) == "134": #Router Advertisement if str(contains_source) == "true-source": for x in range(6): source_link_layer_address = source_link_layer_address + packetHex[ x + offset + 1][2:].zfill(2) + ":" target_address = "n/a" source_link_layer_address = source_link_layer_address[: -1] target_link_layer_address = "n/a" else: source_link_layer_address = "n/a" payload_byte = ethChild2.child().get_bytes() for payload_data in payload_byte: payloadHex.append(hex(payload_data)) router_lifetime = payloadHex[2][2:] + payloadHex[3][2:] elif str(ndp_message_number) == "135": #Neighbor Solicitation for x in range(16): target_address = target_address + packetHex[x][ 2:].zfill(2) if (x > 0): if x % 2 != 0: target_address = target_address + ":" target_address = target_address[:-1] target_link_layer_address = "n/a" if str(contains_source) == "true-source": for x in range(6): source_link_layer_address = source_link_layer_address + packetHex[ x + offset + 1][2:].zfill(2) + ":" source_link_layer_address = source_link_layer_address[: -1] else: source_link_layer_address = "n/a" elif str(ndp_message_number) == "136": #Neighbor Advertisement flags = hex(ethChild2.child().get_bytes()[0:1][0]) if flags == "0xa0": override_flag = True router_flag = True if str(contains_source ) == "true-source" and flags == "0xa0": for x in range(6): target_link_layer_address = target_link_layer_address + packetHex[ 1 + offset + x][2:].zfill(2) + ":" target_link_layer_address = target_link_layer_address[: -1] else: target_link_layer_address = "n/a" for x in range(16): target_address = target_address + packetHex[x][ 2:].zfill(2) if (x > 0): if x % 2 != 0: target_address = target_address + ":" target_address = target_address[:-1] vlanId = self.check_vlanId(buf) message_details = SLAAC_Message.SLAAC_Message( vlanId, ndp_message_number, source_link_layer_address, ip_source_address, ip_destination_address, source_MAC_address_final, destination_MAC_address_final, target_address, target_link_layer_address, override_flag, router_flag, router_lifetime, getInterface) detect_module = Detection.Detection() if str(message_details.get_ndp_message_number() ) == "134": #Last Hop Router Attack detect_module.detect_rogue_advertisement(message_details) elif str(message_details.get_ndp_message_number() ) == "135": #Dos in DAD if str(message_details.get_ip_source_address()) == "::": detect_module.detect_dos_dad(message_details) elif str(message_details.get_ndp_message_number() ) == "136": #Neigbor Spoofing detect_module.detect_neighbor_spoofing((message_details)) except Exception, e: pass