mirror of
https://gitlab.sectorq.eu/jaydee/mqtt_srv.git
synced 2025-12-14 18:44:53 +01:00
bitwarden
This commit is contained in:
88
mqtt_srv.py
88
mqtt_srv.py
@@ -631,94 +631,6 @@ def on_message(client, userdata, msg):
|
|||||||
writeLog("Payload111114")
|
writeLog("Payload111114")
|
||||||
writeLog(output)
|
writeLog(output)
|
||||||
print(json.dumps(serv_d))
|
print(json.dumps(serv_d))
|
||||||
'''
|
|
||||||
if myObj["target"].lower() == "192.168.77.246":
|
|
||||||
dest_ip = "192.168.77.246"
|
|
||||||
elif myObj["target"].lower() == "192.168.77.106":
|
|
||||||
dest_ip = "192.168.77.106"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RULES = ["EMAIL993", "EMAIL995", "EMAIL143", "EMAIL25", "EMAIL993", "EMAIL465", "HTTPS", "HTTP"]
|
|
||||||
for i in RULES:
|
|
||||||
cmnd = "uci set firewall.{}.dest_ip={}".format(i,dest_ip)
|
|
||||||
writeLog(cmnd)
|
|
||||||
subprocess.Popen(cmnd.split())
|
|
||||||
|
|
||||||
#cmnd = "uci set dhcp.@dnsmasq[0].address=/mqtt_broker/" + dest_ip
|
|
||||||
#writeLog(cmnd)
|
|
||||||
#subprocess.Popen(cmnd.split())
|
|
||||||
time.sleep(1)
|
|
||||||
cmnd = "uci commit"
|
|
||||||
|
|
||||||
subprocess.Popen(cmnd.split())
|
|
||||||
|
|
||||||
writeLog("Starting " + myObj["target"].lower())
|
|
||||||
if myObj["target"].lower() == "192.168.77.246":
|
|
||||||
dest_ip = "192.168.77.246"
|
|
||||||
|
|
||||||
|
|
||||||
cmnd = "ssh root@192.168.77.246 'docker start mailu_resolver_1 mailu_redis_1 mailu_front_1 mailu_antispam_1 mailu_imap_1 mailu_admin_1 mailu_smtp_1 mailu_webmail_1 watchtower_watchtower_1 nginx-proxy-manager_db_1 nginx-proxy-manager_app_1 HomeAssistant webhub_client_1 dockermon_docker_mon_1 mosquitto_mosquitto_1 node-red_node-red_1 nextcloud_db_1 nextcloud_app_1'"
|
|
||||||
status, output = subprocess.getstatusoutput(cmnd)
|
|
||||||
elif myObj["target"].lower() == "192.168.77.106":
|
|
||||||
dest_ip = "192.168.77.106"
|
|
||||||
cmnd = "ssh root@192.168.77.246 'docker stop mailu_resolver_1 mailu_redis_1 mailu_front_1 mailu_antispam_1 mailu_imap_1 mailu_admin_1 mailu_smtp_1 mailu_webmail_1 watchtower_watchtower_1 nginx-proxy-manager_db_1 nginx-proxy-manager_app_1 HomeAssistant webhub_client_1 dockermon_docker_mon_1 mosquitto_mosquitto_1 node-red_node-red_1 nextcloud_db_1 nextcloud_app_1'"
|
|
||||||
status, output = subprocess.getstatusoutput(cmnd)
|
|
||||||
time.sleep(1)
|
|
||||||
cmnd = "/etc/init.d/firewall restart"
|
|
||||||
subprocess.Popen(cmnd.split())
|
|
||||||
#cmnd = "/etc/init.d/dnsmasq restart"
|
|
||||||
#subprocess.Popen(cmnd.split())
|
|
||||||
writeLog("reconfigure iot")
|
|
||||||
MQTT_BROKER = dest_ip
|
|
||||||
MQTT_USER = "jaydee"
|
|
||||||
MQTT_PASS = "jaydee1"
|
|
||||||
|
|
||||||
cmnd = "nmap -sP 192.168.77.*|grep \"Nmap scan report\"|egrep -o \"[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\""
|
|
||||||
#print(cmnd)
|
|
||||||
status, output = subprocess.getstatusoutput(cmnd)
|
|
||||||
|
|
||||||
# print(output)
|
|
||||||
|
|
||||||
ips = output.splitlines()
|
|
||||||
tasm_data = {}
|
|
||||||
for sys_ip in ips:
|
|
||||||
# print("Thsis is ip : " + sys_ip)
|
|
||||||
cmnd = "nmap " + sys_ip + " -p80|grep \"80/tcp open http\""
|
|
||||||
status, output = subprocess.getstatusoutput(cmnd)
|
|
||||||
# print("status of 80 : " + str(status))
|
|
||||||
if status == 0:
|
|
||||||
try:
|
|
||||||
# url = "http://" + sys_ip + "/cm?user=admin&password=l4c1j4yd33Du5l0&cmnd=STATUS+5"
|
|
||||||
|
|
||||||
url = "http://" + sys_ip + "/cm?cmnd=Backlog%20MqttHost%20" + MQTT_BROKER + "%3BMqttUser%20" + MQTT_USER + "%3BMqttPassword%20" + MQTT_PASS
|
|
||||||
print(url)
|
|
||||||
requests.get(url)
|
|
||||||
|
|
||||||
except:
|
|
||||||
#print(sys_ip + " : Not a tasmota!")
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
#print(sys_ip + " : Not a listening")
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
time.sleep(1)
|
|
||||||
cmnd = "sed -i 's/^MQTT_HOST = .*/MQTT_HOST = \"" + dest_ip + "\"/' /root/mqtt_srv.py"
|
|
||||||
writeLog(cmnd)
|
|
||||||
status, output = subprocess.getstatusoutput(cmnd)
|
|
||||||
#for i in ;do uci set firewall.${i}.dest_ip=192.168.77.246;done;uci set firewall.HTTPS.dest_port='443';uci set firewall.HTTP.dest_port='80' ;uci commit;/etc/init.d/firewall restart
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
#cmnd = "/root/router_cmd.sh -t wireless -v 0"
|
|
||||||
|
|
||||||
|
|
||||||
print("Executed " + cmnd)
|
|
||||||
writeLog("Executed " + cmnd)
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
if myObj["cmd"] == "banip":
|
if myObj["cmd"] == "banip":
|
||||||
if myObj["status"] == "ban":
|
if myObj["status"] == "ban":
|
||||||
|
|||||||
Reference in New Issue
Block a user