-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathluckyporter.py
executable file
·214 lines (154 loc) · 5.7 KB
/
luckyporter.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/python3
from pyngrok import ngrok
import os
import keyboard
import readline, glob
import sys
import paperclip
import getpass
import pexpect
os.system("clear")
#COLORS
# Python program to print
# colored text and background
def prRed(skk): print("\033[91m {}\033[00m" .format(skk))
def prGreen(skk): print("\033[92m {}\033[00m" .format(skk))
def prYellow(skk): print("\033[93m {}\033[00m" .format(skk))
def prLightPurple(skk): print("\033[94m {}\033[00m" .format(skk))
def prPurple(skk): print("\033[95m {}\033[00m" .format(skk))
def prCyan(skk): print("\033[96m {}\033[00m" .format(skk))
def prLightGray(skk): print("\033[97m {}\033[00m" .format(skk))
def prBlack(skk): print("\033[98m {}\033[00m" .format(skk))
def prHighLight(skk): print("\033[103m {}\033[00m" .format(skk))
##Auto dir complete ##
def complete(text, state):
return (glob.glob(text+'*')+[None])[state]
file_holder = []
command_list = []
weblist = []
show_files = []
#check Ngrok token
def token_check():
pass
# HTTP SERVER
def http_server():
child = pexpect.spawn("/bin/bash")
child.sendline("cd /var/www/html")
child.sendline(f"python -m SimpleHTTPServer {port}")
prYellow('Press "q" if your files are uplaoded successsfully')
prRed('Press "ctrl+c" to force stop')
print(f'''
HTTP Server : {new_ip}
Hope, you have specified a right path or paths.
''')
intrupt(weblist)
# A function to send or to recive Files
def sendrev():
global askforsr
global port
global new_ip
prPurple("@luckythandel")
askforsr = input(f'''
---Actions---
(1.) Send
(2.) Receive
(3.) Exit
Choose one - [1,2,3]
\n==> ''')
if askforsr == "1":
port = input("\n[+] Port\n==> ")
new_ip = ngrok.connect(port, "http")
#TAB AUTO Complete
readline.set_completer_delims(' \t\n;')
readline.parse_and_bind("tab: complete")
readline.set_completer(complete)
filenames = input("\n[+] FILENAME: ")
#END
if len(filenames) == 0:
prRed("Not valid Input, Try again.\n")
sendrev()
else:
print("Your files have been selected!")
splited_files = filenames.split(" ")
for one_file in range(0,len(splited_files[:])):
file_holder.append(splited_files[one_file])
web_file = os.path.basename(splited_files[one_file])
weblist.append(web_file)
prGreen(f"Your file is: {weblist[one_file]}\n")
new_file = file_holder[one_file]
os.system(f"cp -r {new_file} /var/www/html")
global realfile
realfile = weblist[one_file]
Command1 = f'''
[+] Run This Command On The Server
==> wget {new_ip}/{realfile}
'''
prLightPurple(Command1)
else:
http_server()
elif askforsr == "2":
print("\nYou have chosed to recieve files\n")
prGreen("What would you like to use to recieve File.")
ques2 = input('''
(1.) Netcat
(2.) Wget
(3.) curl
choose one - [1,2,3]
\n==>''')
ques3 = input("\nFile name to saved as\n==> ")
if ques2 == "1":
prYellow('''
###WARNING###
Script won't check if the File exist or if the host is down or not.
You will need to check it yourself. provide correct information to
downlaod the files.
''')
token = input("[+] Ngrok Token\n==> ")
ngrok.set_auth_token(token)
ques5 = input("\nPort\n==> ")
new_ip = ngrok.connect(int(ques5), 'tcp')
new_ip1 = new_ip.split("/")
ngrok_ip = new_ip1[2]
new_ip2 = ngrok_ip.split(":")
ngrok_ip2 = new_ip2[0]
ngrok_port = new_ip2[1]
prLightPurple(f'''
[+] Run This Command On Server:
==> nc {ngrok_ip2} {ngrok_port} < <File Path>
''')
child = pexpect.spawn("/bin/bash")
child.sendline(f"nc -lvp {ques5} > {ques3} ")
child.interact()
prGreen("Your file is downloaded!")
ngrok.kill()
exit(0)
elif ques2 == "2":
server_ip = input("\nServer Address [exp: http://example.in/]\n==> ")
if server_ip.endswith("/"):
os.system(f"wget {server_ip}{ques3}")
else:
os.system(f"wget {server_ip}/{ques3}")
elif ques2 == "3":
server_ip = input("\nServer Address [exp: http://example.in/]\n==> ")
if server_ip.endswith("/"):
os.system(f"curl {server_ip}{ques3}")
else:
os.system(f"curl {server_ip}/{ques3}")
else:
prRed("\nPress Ctrl+c to exit\n")
exit(0)
else:
prGreen("Exiting...")
exit(0)
def intrupt(arg1):
while True:
if keyboard.is_pressed("q"):
for remove_file in range(0,len(arg1[:])):
print(arg1[remove_file])
os.chdir("/var/www/html")
os.system('pwd')
os.system(f"rm -r {arg1[remove_file]}")
prYellow("\n[+] All the files have been removed from the /var/www/html\n")
ngrok.kill()
exit(0)
sendrev()