xray 是什么?
import requests
requests.post(webhook, json=vuln_info)
xray 的 webhook 是什么?
from flask import Flask, request
import requests
app = Flask(__name__)
def xray_webhook():
print(request.json)
return 'ok'
if __name__ == '__main__':
app.run()
* Serving Flask app "app.py"
* Environment: development
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
{'create_time': 1566836256580, 'detail': {'host': 'pentester-web.vulnet', 'param': {'key': 'name', 'position': 'query', 'value': "root'and'lW'='lql"}, 'payload': "root'and'lW'='lql", 'port': 80, 'request': '', 'request1': 'GET /sqli/example1.php?name=root%27and%274w%27%3D%274w HTTP/1.1\r\nHost: pentester-web.vulnet\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169\r\nCookie: key=value\r\nAccept-Encoding: gzip\r\n\r\n', 'request2': 'GET /sqli/example1.php?name=root%27and%27lW%27%3D%27lql HTTP/1.1\r\nHost: pentester-web.vulnet\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169\r\nCookie: key=value\r\nAccept-Encoding: gzip\r\n\r\n', 'response': '', 'response1': 'HTTP/1.1 200 OK\r\n...', 'response2': 'HTTP/1.1 200 OK\r\n...', 'title': "Generic Boolean based case ['string']", 'type': 'boolean_based', 'url': 'http://pentester-web.vulnet/sqli/example1.php?name=root'}, 'plugin': 'sqldet', 'target': {'url': 'http://pentester-web.vulnet/sqli/example1.php', 'params': [{'position': 'query', 'path': ['name']}]}, 'vuln_class': ''}
127.0.0.1 - - [27/Aug/2019 00:17:36] "POST /webhook HTTP/1.1" 200 -
from flask import Flask, request
import requests
app = Flask(__name__)
def xray_webhook():
vuln = request.json
content = """## xray 发现了新漏洞
url: {url}
插件: {plugin}
漏洞类型: {vuln_class}
发现时间: {create_time}
请及时查看和处理
""".format(url=vuln["target"]["url"], plugin=vuln["plugin"],
vuln_class=vuln["vuln_class"] or "Default",
create_time=str(datetime.datetime.fromtimestamp(vuln["create_time"] / 1000)))
print(content)
return 'ok'
if __name__ == '__main__':
app.run()
科普一下什么是 Server 酱?
登入:用 GitHub 账号登录 http://sc.ftqq.com/3.version,就能获得一个 SECKEY
绑定:扫码关注完成绑定
发消息:往 http://sc.ftqq.com/{SECKEY}.send 发请求,就可以在微信里收到消息啦
我们先用 Python 写一个简单的 demo,以下所有的 SECKEY 的实际值我都使用 {SECKEY} 代替,大家需要修改为自己的值。
import requests
requests.post("https://sc.ftqq.com/{SECKEY}.send",
data={"text": "xray vuln alarm", "desp": "test content"})
from flask import Flask, request
import requests
import datetime
import logging
app = Flask(__name__)
def push_ftqq(content):
resp = requests.post("https://sc.ftqq.com/{SECKEY}.send",
data={"text": "xray vuln alarm", "desp": content})
if resp.json()["errno"] != 0:
raise ValueError("push ftqq failed, %s" % resp.text)
def xray_webhook():
vuln = request.json
content = """## xray 发现了新漏洞
url: {url}
插件: {plugin}
漏洞类型: {vuln_class}
发现时间: {create_time}
请及时查看和处理
""".format(url=vuln["target"]["url"], plugin=vuln["plugin"],
vuln_class=vuln["vuln_class"] or "Default",
create_time=str(datetime.datetime.fromtimestamp(vuln["create_time"] / 1000)))
try:
push_ftqq(content)
except Exception as e:
logging.exception(e)
return 'ok'
if __name__ == '__main__':
app.run()
企业微信群机器人如何实现自动告警?
def push_wechat_group(content):
resp = requests.post("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={KEY}",
json={"msgtype": "markdown",
"markdown": {"content": content}})
if resp.json()["errno"] != 0:
raise ValueError("push wechat group failed, %s" % resp.text)