Replace nc.exe for a better one
This commit is contained in:
parent
0e3d6c171e
commit
3c92425126
@ -6,6 +6,7 @@ This too has several functions:
|
|||||||
|
|
||||||
## To-Do
|
## To-Do
|
||||||
|
|
||||||
|
* Chisel
|
||||||
* Prettier code
|
* Prettier code
|
||||||
* Only update once per day, except if `-u` `--update`
|
* Only update once per day, except if `-u` `--update`
|
||||||
* Adding more services to listen to ?
|
* Adding more services to listen to ?
|
||||||
|
@ -17,9 +17,6 @@
|
|||||||
"MS11-046/ms11-046.exe",
|
"MS11-046/ms11-046.exe",
|
||||||
"MS11-046/MS11_46_k8.exe",
|
"MS11-046/MS11_46_k8.exe",
|
||||||
"MS10-059/MS10-059.exe"
|
"MS10-059/MS10-059.exe"
|
||||||
],
|
|
||||||
"diegocr/netcat": [
|
|
||||||
"nc.exe"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"githubreleasesync": {
|
"githubreleasesync": {
|
||||||
@ -51,5 +48,11 @@
|
|||||||
"ncat.exe",
|
"ncat.exe",
|
||||||
"ncat"
|
"ncat"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"netcat": {
|
||||||
|
"local_version": "1.12",
|
||||||
|
"files": [
|
||||||
|
"nc.exe"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,6 +10,8 @@ from io import BytesIO
|
|||||||
import zipfile
|
import zipfile
|
||||||
import rpmfile
|
import rpmfile
|
||||||
import gzip
|
import gzip
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
def compute_file_hash(filepath):
|
def compute_file_hash(filepath):
|
||||||
@ -191,6 +193,59 @@ def ncatsync(conf):
|
|||||||
json.dump(data, jsonfile, indent=4)
|
json.dump(data, jsonfile, indent=4)
|
||||||
|
|
||||||
|
|
||||||
|
def netcatsync(conf):
|
||||||
|
# https://eternallybored.org/misc/netcat/ seems to be the most stable from all tested. (04/2022)
|
||||||
|
r = requests.get('https://eternallybored.org/misc/netcat/')
|
||||||
|
soup = BeautifulSoup(r.content, 'lxml')
|
||||||
|
versions = []
|
||||||
|
for link in soup.find_all('a', {'href': re.compile('netcat.+win.+')}):
|
||||||
|
version = link['href'].split('-')[-1].split('.zip')[0]
|
||||||
|
versions.append(version)
|
||||||
|
|
||||||
|
last_version = max(versions)
|
||||||
|
local_version = conf['local_version']
|
||||||
|
|
||||||
|
for filename in conf['files']:
|
||||||
|
# nc64.exe is also available in the archive feel free to add it.
|
||||||
|
localfile = Path('files').joinpath(Path(filename).name)
|
||||||
|
print(f" * {localfile} ", end='')
|
||||||
|
|
||||||
|
archtype = 'zip'
|
||||||
|
binpath = filename
|
||||||
|
destpath = f'files/{filename}'
|
||||||
|
urldl = f'https://eternallybored.org/misc/netcat/netcat-win32-{last_version}.zip'
|
||||||
|
|
||||||
|
if not localfile.exists():
|
||||||
|
content = requests.get(urldl).content
|
||||||
|
extract_bin(archtype, binpath, destpath, content)
|
||||||
|
|
||||||
|
print('-> Installed! ;)')
|
||||||
|
else:
|
||||||
|
if local_version == last_version:
|
||||||
|
print('-> Up-to-date.')
|
||||||
|
|
||||||
|
else:
|
||||||
|
content = requests.get(urldl).content
|
||||||
|
extract_bin(archtype, binpath, destpath, content)
|
||||||
|
|
||||||
|
with open("config.json", "r") as jsonfile:
|
||||||
|
data = json.load(jsonfile)
|
||||||
|
|
||||||
|
data['netcat']['local_version'] = last_version
|
||||||
|
|
||||||
|
with open("config.json", "w") as jsonfile:
|
||||||
|
json.dump(data, jsonfile, indent=4)
|
||||||
|
print('-> Updated!')
|
||||||
|
|
||||||
|
with open("config.json", "r") as jsonfile:
|
||||||
|
data = json.load(jsonfile)
|
||||||
|
|
||||||
|
data['netcat']['local_version'] = last_version
|
||||||
|
|
||||||
|
with open("config.json", "w") as jsonfile:
|
||||||
|
json.dump(data, jsonfile, indent=4)
|
||||||
|
|
||||||
|
|
||||||
def update(config):
|
def update(config):
|
||||||
print("Updating...")
|
print("Updating...")
|
||||||
with open("credz.json", "r") as jsonfile:
|
with open("credz.json", "r") as jsonfile:
|
||||||
@ -204,6 +259,7 @@ def update(config):
|
|||||||
githubreleasesync(reponame, repoinfo, credz)
|
githubreleasesync(reponame, repoinfo, credz)
|
||||||
|
|
||||||
ncatsync(config['ncat'])
|
ncatsync(config['ncat'])
|
||||||
|
netcatsync(config['netcat'])
|
||||||
make_executable()
|
make_executable()
|
||||||
|
|
||||||
|
|
||||||
@ -366,7 +422,8 @@ def menu_choice(menu_options):
|
|||||||
elif option == 3:
|
elif option == 3:
|
||||||
listen_smb(files_dir, 2)
|
listen_smb(files_dir, 2)
|
||||||
elif option == 0:
|
elif option == 0:
|
||||||
sys.exit('Quitting')
|
print('Quitting')
|
||||||
|
sys.exit()
|
||||||
else:
|
else:
|
||||||
print('Invalid option. Please enter a valid number.')
|
print('Invalid option. Please enter a valid number.')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user