Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python cmd调用运行异常 #27

Closed
notwhy opened this issue Sep 22, 2020 · 2 comments
Closed

python cmd调用运行异常 #27

notwhy opened this issue Sep 22, 2020 · 2 comments

Comments

@notwhy
Copy link

notwhy commented Sep 22, 2020

mac客户端 ksudomain最新版
在pycharm中通过os.system或者subprocess.Popen来调用ksubdomain会卡死,原因不明。
1.比如下面的trigger.py文件在pycharm卡死

import os,subprocess

ksubdomain_cmd = './ksubdomain1 -skip-wild -d wanmei.com'
p = subprocess.Popen(ksubdomain_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while True:
    output = p.stdout.readline()
    if output == '' and p.poll() is not None:
        break
    if output:
        print(output)

一直保存在该界面 且无dns数据包发送 wireshark无法抓包。
image
当停止运行时偶尔会出现奇怪的dns请求
image
而单独在cmd下运行该文件可以成功发出dns数据包。
2.用分布式celery封装ksubdomain后,发现还是无法运行,测试机器ubuntu,centos

不清楚这个的原因,望能解惑。

@boy-hack
Copy link
Contributor

ksubdomain支持管道输入,在python中如果不指定input可能导致读取管道阻塞。
一个简单的调用方法

output = "output.txt"
bandwith = "5m"
dict_set = ['www.baidu.com']
cmd = [ksubdomain, "-o", output, "-b", bandwith, "-l", "2", "-skip-wild", "-verify"]
timeout = 60 * 60 * 5
try:
    subprocess.run(cmd, input='\n'.join(dict_set).encode(), shell=False, timeout=timeout)
except subprocess.TimeoutExpired:
    print("[x] 因为扫描超时被kill~")

@notwhy
Copy link
Author

notwhy commented Sep 22, 2020

感谢,已解决,使用echo "" | ksubdomain

@notwhy notwhy closed this as completed Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants