forked from 0x00-0x00/ShellPop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
73 lines (56 loc) · 2.3 KB
/
setup.py
File metadata and controls
73 lines (56 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from setuptools import setup
from setuptools.command.install import install
from subprocess import Popen, PIPE
import os
def applyChanges():
# Running "source ~/.bashrc" in a subprocess does NOTHING to the current shell.
# But to keep original behavior, we leave it.
proc = Popen("bash -c 'source ~/.bashrc'", stdout=PIPE, stderr=PIPE, shell=True)
proc.communicate()
return None
def activateTabComplete():
proc = Popen("activate-global-python-argcomplete",
stdout=PIPE, stderr=PIPE, shell=True)
proc.communicate()
return proc.poll() == 0 # FIXED: "is 0" → "== 0"
def autoComplete():
"""
Get the content required to register Shellpop into tab auto-completion
@zc00l
"""
proc = Popen("register-python-argcomplete shellpop",
stdout=PIPE, stderr=PIPE, shell=True)
stdout, _ = proc.communicate()
# stdout is bytes in Python 3 → decode to string
return stdout.decode("utf-8")
class CustomInstall(install):
def run(self):
super().run()
bashrc_file = os.path.join(os.environ["HOME"], ".bashrc")
if not os.path.exists(bashrc_file):
return None
with open(bashrc_file, "r") as f:
bashrc_content = f.read()
if "shellpop" not in bashrc_content:
print("Registering shellpop in .bashrc for auto-completion ...")
activateTabComplete()
# Append auto-complete script to .bashrc
with open(bashrc_file, "a") as f:
f.write("\n{}\n".format(autoComplete()))
print("Auto-completion has been installed.")
applyChanges()
setup(
name='shellpop',
version='0.3.6',
description='Bind and Reverse shell code generator to aid Penetration Tester in their work. Originally dev by authors (zc00l, lowfuel, touhidshaikh) in python2; forked and updated by rizwanbinyasin in python3',
url='https://github.com/rizwanbinyasin/ShellPop.git',
author='rizwanbinyasin',
author_email='rizwanbinyasin@gmail.com',
license='MIT',
packages=['shellpop'],
package_dir={"shellpop": "src"},
package_data={"shellpop": ["src/*"]},
scripts=["bin/shellpop"],
zip_safe=False,
cmdclass={'install': CustomInstall}
)