Shodan_So
Shodan_So copied to clipboard
会员怎么也只有一百条
会员怎么也只有查到一百条
请问是使用的哪个功能呢?默认是显示一页100条,可尝试更改--page
参数
请问,修改--page还是100条数据
只能修改页数,不能修改输出结果数量
我在写我的工具的时候也遇到了这个问题,纳闷了半天,原来问题出在这里!谢谢大家的解答!中文社区如csdn里面根本就没人涉及到这一块。
请问,修改--page还是100条数据
我刚刚遇到了这个问题,于是我看了一下,并写了篇文章讲述这个问题:https://blog.csdn.net/NicolasZQ/article/details/125652542
会员怎么也只有查到一百条
我刚刚遇到了这个问题,于是我看了一下,并写了篇文章讲述这个问题:https://blog.csdn.net/NicolasZQ/article/details/125652542
文章由于版权问题被封了,我把文章提出来:
问题产生
今天我在写我的工具(http://github.com/W01fh4cker/Serein
)的时候,需要调用shodan
,于是我采用了python
的shodan
库。但是在调用这个库的时候却发现,我的账号明明是会员,用shodaninfo()
查询的我的shodan
的信息也是没问题的。
问题解决
参考github
上的这个issues
:
https://github.com/zev3n/Shodan_So/issues/1
知道了这一点之后,我去翻了官方文档:
https://shodan.readthedocs.io/en/latest/tutorial.html?searching-shodan
在这里我看到了官方其实是有说明的:
那我们就去源代码里面看看能否自定义页数,答案是没问题
现在我们只需要遍历一下页数即可获取全部数据了。
我这里给出一个小的
demo
,大家可以自行修改:
from concurrent.futures import ThreadPoolExecutor
import shodan
def shodan_muti_search(key):
SHODAN_API_KEY = key
api = shodan.Shodan(SHODAN_API_KEY)
try:
shodan_search_sentence = input("请输入您的shodan查询语句:")
shodan_number = input("请输入您想要查询的页数:")
shodan_number = int(shodan_number)
page_number = shodan_number / 100
pagenumber = page_number + 1
pagenumber = int(pagenumber)
for j in range(1, pagenumber):
results = api.search(shodan_search_sentence, page=j)
for i in range(0,100):
# 把采集的url写入文件中
with open('采集的url.txt', 'a+') as f:
ip_str = results['matches'][i]['ip_str']
port = results['matches'][i]['port']
# 使获取到的url符合规范
if port is not None:
shodan_got_url1 = "https://" + str(ip_str) + ":" + str(port) + '\n'
f.write(shodan_got_url1)
print(shodan_got_url1)
else:
shodan_got_url2 = "https://" + str(ip_str) + '\n'
f.write(shodan_got_url2)
print(shodan_got_url2)
print("【+】保存成功!文件就在您的当前文件夹下的【采集的url.txt】里。\n")
except Exception as e:
print("【×】出错了,请检查您的账号是否有调用API查询该语句的权限!报错内容:" + str(e) + "\n")
if __name__ == "__main__":
SHODAN_API_KEY = input("请输入您的API-KEY:")
max_thread_num = 100 # 设置线程数是100
executor = ThreadPoolExecutor(max_workers=max_thread_num)
future = executor.submit(shodan_muti_search, SHODAN_API_KEY) # 第一个参数是函数,第二个参数是这个函数的参数。
如果你还有什么问题,可以直接在评论区留言,一定及时回复;如果你的问题非常紧急,不妨加我的微信:W01fh4cker
,一起探讨。