do_scan_port.py
#!/usr/bin/env python
#-*-CODING:GBK-*-
#-*-coding:utf_8-*-
import socket from
do_valid_ip import *
# SCAN Specifies IP port
def test_port (dst,port):
os.system (' title ' +str (port))
Cli_sock = socket.socket (socket . af_inet, Socket. Sock_stream
Try:
indicator = CLI_SOCK.CONNECT_EX ((DST, Port)
cli_sock.close ()
If indicator = 0: Return is
True
else: return
False
except: Pass
ip_prefix = "172.18.228";
Find_port = 5555
print "Start scan valid port" + str (find_port)
for I in range (1, 256):
IP = '%s.%s '% (IP _prefix, i)
if Ping_ip (IP):
Porton = Test_port (IP, 5555);
If Porton:
print IP + "got valid port"
print "End scan valid port" + str (find_port)
do_valid_ip.py
#-*-Coding:utf-8-*-# author:orangleliu date:2014-11-12 # python2.7.x ip_scaner.py ' "' Scan active IP execution in LAN: Python IP_SC aner.py 192.168.1.1 ' Import platform import sys import OS import time import thread Def get_os (): "' Get O S type ' OS = Platform.system () If OS = "Windows": Return "n" Else:return "C" def Ping _ip (ip_str): cmd = ["Ping", "-{op}". Format (Op=get_os ()), "1", ip_str] output = Os.popen ("". Join (CMD)). ReadLines () flag = False for line in list (output): If not line:continue if Str
. Upper (). Find ("TTL") >= 0:flag = True break if Flag:return true else:
Return False def find_ip (ip_prefix): "" gives the current 127.0.0, then scans the entire segment for all addresses ' for I-in range (1, 256): ip = '%s.%s '% (Ip_prefix, i) Thread.start_new_thread (ping_ip, (IP,)) Time.sleep (0.3) If __name__ = "__ main__ ": print" starT time%s "% time.ctime () Commandargs = sys.argv[1:] args =" ". Join (Commandargs) Ip_prefix = '. '. Join (Args.split ('. ')
[:-1])
FIND_IP (ip_prefix) print "End time%s"% Time.ctime ()
If Port 5555 is open, combine ADB remote debugging/Network debugging can control the phone.