shodan高级搜索及api脚本打包为单文件教程

120次阅读

共计 1399 个字符,预计需要花费 4 分钟才能阅读完成。

挺多用 shodan 的 mjj,这里发些高级点的搜索参数,注意 shodan 不支持正则匹配,所以下面的值都要是全名。
server=”xxx”  // 值可以是 nginx 或者 apache 等等
country:”SG” // 国家
port:”443″ // 开启的端口
asn:”asxxxx” // asn

api 使用方法
1,打开 https://account.shodan.io/  找到 API Key
2,安装 python3 和 pip
3,pip install shodan
4,复制下面代码到 sd.py 文件,注意 API Key 替换为第一步的 key

  1. import argparse
  2. import shodan
  3. # Configuration
  4. API_KEY = “xxx”
  5. parser = argparse.ArgumentParser(description=’Process shodan search’)
  6. parser.add_argument(‘filters’, type=str, nargs=’+’, help=’shodan search filters’)
  7. parser.add_argument(‘-p’, type=int, default=1, metavar=’page’, help=’page number’)
  8. args = parser.parse_args()
  9. try:
  10.         # Setup the api
  11.         api = shodan.Shodan(API_KEY)
  12.         # Perform the search
  13.         query = ‘ ‘.join(args.filters)
  14.         result = api.search(query, args.p)
  15.         # Loop through the matches and print each IP
  16.         for service in result[‘matches’]:
  17.                 print (service[‘ip_str’])
  18. except Exception as e:
  19.         print (‘Error: %s’ % e)

复制代码

5,运行命令 python3 sd.py server=”xxx” country:”SG” port:”443″ asn:”asxxx” -p 2
注意,shodan api 一次只能返回最多 100 条结果,一个月最多 10000 条结果

打包为可执行单文件方法,这样不用安装 python 和 shodan 就可以调 api 了
1,apt install build-essential python3-dev patchelf ccache
2,pip install virtualenv
3,virtualenv venv
4,cd venv && source bin/activate
5,pip install orderedset zstandard shodan
6,pip install -U –force-reinstall “https://github.com/Nuitka/Nuitka/archive/develop.zip”
7,复制 sd.py 到当前目录
8,python3 -m nuitka –onefile sd.py
9,运行./sd.bin server=”xxx” country:”SG” port:”443″ asn:”asxxx”

网友回复:

注册 有漏洞让我直接抓一堆肉鸡挖矿吗

xqdoo00o 注意这个是转到 c 语言编译了,速度比直接打包 py 快点

正文完
 0