本文整理汇总了Python中subprocess.Popen.findall方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.findall方法的具体用法?Python Popen.findall怎么用?Python Popen.findall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subprocess.Popen
的用法示例。
在下文中一共展示了Popen.findall方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_scan
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import findall [as 别名]
def do_scan(self, port="80", num="10", needdetail="0"):
path = os.getcwd()
# p= Popen(" ./zmap -B 4M -p "+port+" -N "+num+" -q -O json", stdout=PIPE, shell=True,cwd=path+'/zmap-2.1.0/src')
p = Popen(
" zmap -w /root/github/Scan-T/spidermanage/spidertool/iparea.json -B 1M -p "
+ port
+ " -N "
+ num
+ " -q -O json",
stdout=PIPE,
shell=True,
)
# 'sudo zmap -p 80 -B 10M -N 50 -q --output-fields=classification,saddr,daddr,sport,dport,seqnum,acknum,cooldown,repeat -o - '+
# '| sudo ./forge-socket -c 50 -d http-req > http-banners.out'
# p= Popen(" ./zmap -B 10M -p 80 -n 100000 ", stdout=PIPE, shell=True,cwd=path+'/zmap-2.1.0/src')
p.wait()
retcode = p.returncode
if retcode == 0:
returnmsg = p.stdout.read()
p = re.compile(r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}")
list = p.findall(returnmsg)
# self.sqlTool.connectdb()
localtime = str(time.strftime("%Y-%m-%d %X", time.localtime()))
insertdata = []
jobs = []
for i in list:
insertdata.append((str(i), port, localtime, "open", str(port)))
self.getlocationtool.add_work([str(i)])
if needdetail == "0":
global portname
nowportname = portname.get(port, "")
self.portscan.add_work([(nowportname, str(i), port, "open", "", "")])
else:
ajob = job.Job(jobaddress=str(i), jobport="", forcesearch="0", isjob="0")
jobs.append(ajob)
if needdetail != "0":
tasktotally = sniffertask.getObject()
tasktotally.add_work(jobs)
extra = " on duplicate key update state='open' , timesearch='" + localtime + "'"
# self.sqlTool.inserttableinfo_byparams(table=self.config.porttable,select_params=['ip','port','timesearch','state'],insert_values=insertdata,extra=extra)
sqldatawprk = []
dic = {
"table": self.config.porttable,
"select_params": ["ip", "port", "timesearch", "state", "portnumber"],
"insert_values": insertdata,
"extra": extra,
}
tempwprk = Sqldata.SqlData("inserttableinfo_byparams", dic)
sqldatawprk.append(tempwprk)
self.sqlTool.add_work(sqldatawprk)
示例2: do_scan
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import findall [as 别名]
def do_scan(self,port='80',num='10',needdetail='0'):
path=os.getcwd()
# p= Popen(" ./zmap -B 4M -p "+port+" -N "+num+" -q -O json", stdout=PIPE, shell=True,cwd=path+'/zmap-2.1.0/src')
p= Popen(" zmap -w /root/github/Scan-T/spidermanage/spidertool/iparea.json -B 1M -p "+port+" -N "+num+" -q -O json", stdout=PIPE, shell=True)
# 'sudo zmap -p 80 -B 10M -N 50 -q --output-fields=classification,saddr,daddr,sport,dport,seqnum,acknum,cooldown,repeat -o - '+
# '| sudo ./forge-socket -c 50 -d http-req > http-banners.out'
#p= Popen(" ./zmap -B 10M -p 80 -n 100000 ", stdout=PIPE, shell=True,cwd=path+'/zmap-2.1.0/src')
p.wait()
retcode= p.returncode
if retcode==0:
returnmsg=p.stdout.read()
p = re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
list= p.findall(returnmsg)
# self.sqlTool.connectdb()
localtime=str(time.strftime("%Y-%m-%d %X", time.localtime()))
insertdata=[]
jobs=[]
p=0
for i in list:
insertdata.append((str(i),port,localtime,'open',str(port)))
p=p+1
if p==20 or i==list[len(list)-1]:
extra=' on duplicate key update state=\'open\' , timesearch=\''+localtime+'\''
sqldatawprk=[]
dic={"table":self.config.porttable,"select_params":['ip','port','timesearch','state','portnumber'],"insert_values":insertdata,"extra":extra}
tempwprk=Sqldata.SqlData('inserttableinfo_byparams',dic)
sqldatawprk.append(tempwprk)
self.sqlTool.add_work(sqldatawprk)
p=0
insertdata=[]
if needdetail!='0':
tasktotally=sniffertask.getObject()
tasktotally.add_work(jobs)
jobs=[]
if needdetail=='0':
global portname
nowportname=portname.get(port,'')
self.portscan.add_work([(nowportname,str(i),port,'open','','')])
else:
ajob=job.Job(jobaddress=str(i),jobport='',forcesearch='0',isjob='0')
jobs.append(ajob)
示例3: dig
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import findall [as 别名]
def dig(s='smtp.gmail.com', verbose=False):
import os
p = Popen("dig smtp.gmail.com", shell=True, stdout=PIPE, close_fds=True, bufsize=4096, stderr=PIPE, stdin=PIPE)
a, b, c = (p.stdin, p.stdout, p.stderr)
s = b.read()
if verbose: print s
s = s.split(';; ANSWER SECTION:')[-1]
s = s.split(';;')[0]
i = s.find('\n')
s = s[i:]
import re
p = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
xs = p.findall(s)
if verbose: print xs
return xs