Advertisement
Guest User

Untitled

a guest
Nov 19th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.44 KB | None | 0 0
  1. __author__ = 'User'
  2.  
  3. from socket import *
  4. from re import *
  5. import os
  6. import sys
  7. import time
  8.  
  9.  
  10. commands = ["SAVE", "ECHO", "GIVEIP", "UPTIME", "WHOAMI", "MOVETO", "RUN", "PRINTF", "GOAWAYF", "GOAWAYD", "MAKEF", "MAKED", "COPYF", "EXEC", "DL", "!CONNECT_UPTIME", "!HELP", "!ABOUT", "!LOGOUT", "PING", "GET", "SCREENSHOT"]
  11. connection_started = time.time()
  12.  
  13. def main():
  14. soc = socket()
  15. ip = raw_input("Enter ip address to connect to: ")
  16. port = input("Enter port to use: ")
  17. soc.connect((ip, port))
  18.  
  19. F_CONNECT_S(soc)
  20.  
  21. if not(os.path.isdir("Downloads")):
  22. os.mkdir("Downloads")
  23.  
  24. #Starting measuring time(connection time)
  25. connection_started = time.time()
  26.  
  27. command = [""]
  28. while not (command[0] == "!LOGOUT" or (command[0] == "SAVE" and command[1] == "!LOGOUT")):
  29. command = menu()
  30. if(command[0] == "ECHO"):
  31. F_ECHO_S(soc, command[1], command[-1])
  32. elif (command[0] == "GIVEIP"):
  33. F_GIVEIP_S(soc, command[-1])
  34. elif (command[0] == "UPTIME"):
  35. F_UPTIME_S(soc, command[-1])
  36. elif (command[0] == "WHOAMI"):
  37. F_WHOAMI_S(soc, command[-1])
  38. elif (command[0] == "MOVETO"):
  39. F_MOVETO_S(soc,command[1], command[-1])
  40. elif (command[0] == "RUN"):
  41. F_RUN_S(soc,command[1], command[-1])
  42. elif (command[0] == "PRINTF"):
  43. F_PRINTF_S(soc,command[1], command[-1])
  44. elif (command[0] == "GOAWAYF"):
  45. F_GOAWAYF_S(soc,command[1, command[-1]])
  46. elif (command[0] == "GOAWAYD"):
  47. F_GOAWAYD_S(soc,command[1], command[-1])
  48. elif (command[0] == "MAKEF"):
  49. F_MAKEF_S(soc,command[1], command[-1])
  50. elif (command[0] == "MAKED"):
  51. F_MAKED_S(soc,command[1], command[-1])
  52. elif (command[0] == "COPYF"):
  53. F_COPYF_S(soc,command[1],command[2, command[-1]])
  54. elif (command[0] == "EXEC"):
  55. F_EXEC_S(soc,command[1], command[-1])
  56. elif (command[0] == "DL"):
  57. F_DL_S(soc,command[1], command[-1])
  58. elif (command[0] == "GET"):
  59. F_GET_S(soc,command[1], command[-1])
  60. elif (command[0] == "PING"):
  61. F_PING_S(soc,command[1], command[-1])
  62. elif (command[0] == "SCREENSHOT"):
  63. F_SCREENSHOT_S(soc, command[-1])
  64. elif(command[0] == "!CONNECT_UPTIME"):
  65. f_CONNECT_UPTIME_C(command[-1])
  66. elif (command[0] == "!HELP" and len(command) == 1):
  67. f_HELP_WITHOUT_ARGUMENT_C(command[-1])
  68. elif (command[0] == "!HELP" and len(command) == 2):
  69. f_HELP_WITH_ARGUMENT_C(command[1], command[-1])
  70. elif(command[0] == "!ABOUT"):
  71. f_ABOUT_C(command[-1])
  72. elif(command[0] == "SAVE"):
  73. if (command[1] == "ECHO"):
  74. F_ECHO_S(soc, command[2], command[-1])
  75. elif (command[1] == "GIVEIP"):
  76. F_GIVEIP_S(soc, command[-1])
  77. elif (command[1] == "UPTIME"):
  78. F_UPTIME_S(soc, command[-1])
  79. elif (command[1] == "WHOAMI"):
  80. F_WHOAMI_S(soc, command[-1])
  81. elif (command[1] == "MOVETO"):
  82. F_MOVETO_S(soc, command[2], command[-1])
  83. elif (command[1] == "RUN"):
  84. F_RUN_S(soc, command[2], command[-1])
  85. elif (command[1] == "PRINTF"):
  86. F_PRINTF_S(soc, command[2], command[-1])
  87. elif (command[1] == "GOAWAYF"):
  88. F_GOAWAYF_S(soc, command[2], command[-1])
  89. elif (command[1] == "GOAWAYD"):
  90. F_GOAWAYD_S(soc, command[2], command[-1])
  91. elif (command[1] == "MAKEF"):
  92. F_MAKEF_S(soc, command[2], command[-1])
  93. elif (command[1] == "MAKED"):
  94. F_MAKED_S(soc, command[2], command[-1])
  95. elif (command[1] == "COPYF"):
  96. F_COPYF_S(soc, command[2], command[3], command[-1])
  97. elif (command[1] == "EXEC"):
  98. F_EXEC_S(soc, command[2], command[-1])
  99. elif (command[1] == "DL"):
  100. F_DL_S(soc, command[2], command[-1])
  101. elif (command[1] == "GET"):
  102. F_GET_S(soc, command[2], command[-1])
  103. elif (command[1] == "PING"):
  104. F_PING_S(soc, command[2], command[-1])
  105. elif (command[1] == "SCREENSHOT"):
  106. F_SCREENSHOT_S(soc, command[-1])
  107. elif (command[1] == "!CONNECT_UPTIME"):
  108. f_CONNECT_UPTIME_C(command[-1])
  109. elif (command[1] == "!HELP" and len(command) == 1):
  110. f_HELP_WITHOUT_ARGUMENT_C(command[-1])
  111. elif (command[1] == "!HELP" and len(command) == 2):
  112. f_HELP_WITH_ARGUMENT_C(command[2], command[-1])
  113. elif (command[1] == "!ABOUT"):
  114. f_ABOUT_C(command[-1])
  115. else:
  116. soc.send(str(command))
  117. data = soc.recv(1024)
  118. print (data)
  119. soc.close()
  120.  
  121. def menu():
  122. isCommandOkay = False
  123. while not(isCommandOkay):
  124. command_list = []
  125. command = raw_input()
  126. command_list = command.split(' ')
  127. if not((command_list[0] in commands)):
  128. print(command_list[0] + " is not recognized as an internal or external command, operable program or batch file.")
  129. elif((command_list[0] == "GIVEIP" or command_list[0] == "UPTIME" or command_list[0] == "WHOAMI" or command_list[0] == "!ABOUT" or command_list[0] == "!LOGOUT" or command_list[0] == "SCREENSHOT") and len(command_list) > 1):
  130. print("Num of arguments is incorrect for \"" + command_list[0] + "\" command!")
  131. elif((command_list[0] == "ECHO" or command_list[0] == "MOVETO" or command_list[0] == "RUN" or command_list[0] == "PRINTF" or command_list[0] == "GOAWAYF" or command_list[0] == "GOAWAYD" or command_list[0] == "MAKEF" or command_list[0] == "MAKED" or command_list[0] == "EXEC" or command_list[0] == "DL" or command_list[0] == "PING" or command_list[0] == "GET") and not(len(command_list) == 2)):
  132. print("Num of arguments is incorrect for \"" + command_list[0] + "\" command!")
  133. elif((command_list[0] == "COPYF") and not(len(command_list) == 3)):
  134. print("Num of arguments is incorrect for \"" + command_list[0] + "\" command!")
  135. elif((command_list[0] == "!HELP") and len(command_list) > 2):
  136. print("Num of arguments is incorrect for \"" + command_list[0] + "\" command!")
  137. elif(command_list[0] == "SAVE"):
  138. if not ((command_list[1] in commands)):
  139. print(command_list[1] + " is not recognized as an internal or external command, operable program or batch file.")
  140. elif ((command_list[1] == "GIVEIP" or command_list[1] == "UPTIME" or command_list[1] == "WHOAMI" or command_list[1] == "!ABOUT" or command_list[1] == "!LOGOUT" or command_list[1] == "SCREENSHOT") and len(command_list) > 2):
  141. print("Num of arguments is incorrect for \"" + command_list[1] + "\" command!")
  142. elif ((command_list[1] == "ECHO" or command_list[1] == "MOVETO" or command_list[1] == "RUN" or command_list[1] == "PRINTF" or command_list[1] == "GOAWAYF" or command_list[1] == "GOAWAYD" or command_list[1] == "MAKEF" or command_list[1] == "MAKED" or command_list[1] == "EXEC" or command_list[1] == "DL" or command_list[1] == "PING" or command_list[1] == "GET") and not (len(command_list) == 3)):
  143. print("Num of arguments is incorrect for \"" + command_list[1] + "\" command!")
  144. elif ((command_list[1] == "COPYF") and not (len(command_list) == 4)):
  145. print("Num of arguments is incorrect for \"" + command_list[1] + "\" command!")
  146. elif ((command_list[1] == "!HELP") and len(command_list) > 3):
  147. print("Num of arguments is incorrect for \"" + command_list[1] + "\" command!")
  148. else:
  149. isCommandOkay = True
  150. command_list.append("YES")
  151. else:
  152. isCommandOkay = True
  153. command_list.append("NO")
  154. return command_list
  155.  
  156. def F_CONNECT_S(soc):
  157. username = raw_input("Enter username: ")
  158. password = raw_input("Enter password: ")
  159. messageToSend = r"CONNECT_1\x2\x" + username + r"\x" + password
  160. soc.send(messageToSend)
  161. answerFromServer = str(soc.recv(1024)).split(r"\x")[1]
  162. while(answerFromServer == "no"):
  163. username = raw_input("Enter username: ")
  164. password = raw_input("Enter password: ")
  165. messageToSend = r"CONNECT_1\x2\x" + username + r"\x" + password
  166. soc.send(messageToSend)
  167. answerFromServer = str(soc.recv(1024)).split(r"\x")[1]
  168.  
  169.  
  170. def F_ECHO_S(soc, command, isSave):
  171. dataToSend = r"ECHO_1\x1\x" + command
  172. soc.send(dataToSend)
  173. dataReceived = soc.recv(1024)
  174. splitedDataReceived = str(dataReceived).split(r"\x")
  175.  
  176. if(isSave == "YES"):
  177. nameOfTheFile = "ECHO - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  178. file = open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w')
  179. file.write(splitedDataReceived[1])
  180. else:
  181. print splitedDataReceived[1]
  182.  
  183. def F_GIVEIP_S(soc, isSave):
  184. dataToSend = r"GIVEIP_1\x0"
  185. soc.send(dataToSend)
  186. dataReceived = soc.recv(1024)
  187. splitedDataReceived = str(dataReceived).split(r"\x")
  188.  
  189. if (isSave == "YES"):
  190. nameOfTheFile = "GIVEIP - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  191. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  192. file.write(splitedDataReceived[1])
  193. else:
  194. print splitedDataReceived[1]
  195.  
  196. def F_UPTIME_S(soc, isSave):
  197. dataToSend = r"UPTIME_1\x0"
  198. soc.send(dataToSend)
  199. dataReceived = soc.recv(1024)
  200. splitedDataReceived = str(dataReceived).split(r"\x")
  201.  
  202. if (isSave == "YES"):
  203. nameOfTheFile = "UPTIME - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  204. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  205. file.write(splitedDataReceived[1])
  206. else:
  207. print splitedDataReceived[1]
  208.  
  209. def F_WHOAMI_S(soc, isSave):
  210. dataToSend = r"WHOAMI_1\x0"
  211. soc.send(dataToSend)
  212. dataReceived = soc.recv(1024)
  213. splitedDataReceived = str(dataReceived).split(r"\x")
  214.  
  215. if (isSave == "YES"):
  216. nameOfTheFile = "WHOAMI - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  217. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  218. file.write(splitedDataReceived[1])
  219. else:
  220. print splitedDataReceived[1]
  221.  
  222. def F_MOVETO_S(soc, command, isSave):
  223. dataToSend = r"MOVETO_1\x1\x" + command
  224. soc.send(dataToSend)
  225. dataReceived = soc.recv(1024)
  226. splitedDataReceived = str(dataReceived).split(r"\x")
  227.  
  228. if (isSave == "YES"):
  229. nameOfTheFile = "MOVETO - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  230. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  231. file.write(splitedDataReceived[1])
  232. else:
  233. print splitedDataReceived[1]
  234.  
  235. def F_RUN_S(soc, command, isSave):
  236. dataToSend = r"RUN_1\x1\x" + command
  237. soc.send(dataToSend)
  238. dataReceived = soc.recv(1024)
  239. splitedDataReceived = str(dataReceived).split(r"\x")
  240.  
  241. if (isSave == "YES"):
  242. nameOfTheFile = "RUN - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  243. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  244. file.write(splitedDataReceived[1])
  245. else:
  246. print splitedDataReceived[1]
  247.  
  248. def F_PRINTF_S(soc, command, isSave):
  249. dataToSend = r"PRINTF_1\x1\x" + command
  250. soc.send(dataToSend)
  251. allData = ""
  252. dataReceived = str(soc.recv(1024))
  253. allData += dataReceived[9:]
  254. while not(dataReceived[-6:] == r"\y\y\y"):
  255. dataReceived = soc.recv(1024)
  256. allData += dataReceived[9:]
  257. allData = allData[:-6]
  258.  
  259. if (isSave == "YES"):
  260. nameOfTheFile = "PRINTF - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  261. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  262. file.write(allData)
  263. else:
  264. print allData
  265.  
  266. def F_GOAWAYF_S(soc, command, isSave):
  267. dataToSend = r"GOAWAYF_1\x1\x" + command
  268. toSend = ""
  269. while not(toSend == "Y" or toSend == "N"):
  270. print "Ary you sure you want to delete " + command + " (Y/N)"
  271. toSend = raw_input()
  272. if(toSend == "Y"):
  273. soc.send(dataToSend)
  274. dataReceived = soc.recv(1024)
  275. splitedDataReceived = str(dataReceived).split(r"\x")
  276.  
  277. if (isSave == "YES"):
  278. nameOfTheFile = "GOAWAYF - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  279. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  280. file.write(splitedDataReceived[1])
  281. else:
  282. print splitedDataReceived[1]
  283.  
  284. def F_GOAWAYD_S(soc, command, isSave):
  285. dataToSend = r"GOAWAYD_1\x1\x" + command
  286. toSend = ""
  287. while not (toSend == "Y" or toSend == "N"):
  288. print "Ary you sure you want to delete " + command + " (Y/N)"
  289. toSend = raw_input()
  290. if (toSend == "Y"):
  291. soc.send(dataToSend)
  292. dataReceived = soc.recv(1024)
  293. splitedDataReceived = str(dataReceived).split(r"\x")
  294.  
  295. if (isSave == "YES"):
  296. nameOfTheFile = "GOAWAYD - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  297. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  298. file.write(splitedDataReceived[1])
  299. else:
  300. print splitedDataReceived[1]
  301.  
  302. def F_MAKEF_S(soc, command, isSave):
  303. dataToSend = r"MAKEF_1\x1\\x" + command
  304. soc.send(dataToSend)
  305. serverAnswer = soc.recv(1024)
  306. splitedDataReceived = str(serverAnswer).split(r"\x")
  307. if(splitedDataReceived[1] == "exist"):
  308. toSend = ""
  309. while not (toSend == "Y" or toSend == "N"):
  310. print "The file is already existed are you sure you want wo overwrite him " + command + " (Y/N)"
  311. toSend = raw_input()
  312. if (toSend == "Y"):
  313. soc.send(r"MAKEF_1\x1\xyes")
  314. dataReceived = soc.recv(1024)
  315. splitedDataReceived = str(dataReceived).split(r"\x")
  316.  
  317. if (isSave == "YES"):
  318. nameOfTheFile = "MAKEF - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  319. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  320. file.write(splitedDataReceived[1])
  321. else:
  322. print splitedDataReceived[1]
  323. elif (toSend == "N"):
  324. soc.send(r"MAKEF_1\x1\xno")
  325. dataReceived = soc.recv(1024)
  326. splitedDataReceived = str(dataReceived).split(r"\x")
  327.  
  328. if (isSave == "YES"):
  329. nameOfTheFile = "MAKEF - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  330. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  331. file.write(splitedDataReceived[1])
  332. else:
  333. print splitedDataReceived[1]
  334. else:
  335. dataReceived = soc.recv(1024)
  336. splitedDataReceived = str(dataReceived).split(r"\x")
  337.  
  338. if (isSave == "YES"):
  339. nameOfTheFile = "MAKEF - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  340. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  341. file.write(splitedDataReceived[1])
  342. else:
  343. print splitedDataReceived[1]
  344.  
  345. def F_MAKED_S(soc, command, isSave):
  346. dataToSend = r"MAKED_1\x1\x" + command
  347. soc.send(dataToSend)
  348. serverAnswer = soc.recv(1024)
  349. splitedDataReceived = str(serverAnswer).split(r"\x")
  350. if (splitedDataReceived[1] == "exist"):
  351. toSend = ""
  352. while not (toSend == "Y" or toSend == "N"):
  353. print "The Directory is already existed are you sure you want wo overwrite him " + command + " (Y/N)"
  354. toSend = raw_input()
  355. if (toSend == "Y"):
  356. soc.send(r"MAKED_1\x1\xyes")
  357. dataReceived = soc.recv(1024)
  358. splitedDataReceived = str(dataReceived).split(r"\x")
  359.  
  360. if (isSave == "YES"):
  361. nameOfTheFile = "MAKED - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  362. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  363. file.write(splitedDataReceived[1])
  364. else:
  365. print splitedDataReceived[1]
  366. elif (toSend == "N"):
  367. soc.send(r"MAKED_1\x1\xno")
  368. dataReceived = soc.recv(1024)
  369. splitedDataReceived = str(dataReceived).split(r"\x")
  370.  
  371. if (isSave == "YES"):
  372. nameOfTheFile = "MAKED - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  373. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  374. file.write(splitedDataReceived[1])
  375. else:
  376. print splitedDataReceived[1]
  377. else:
  378. dataReceived = soc.recv(1024)
  379. splitedDataReceived = str(dataReceived).split(r"\x")
  380.  
  381. if (isSave == "YES"):
  382. nameOfTheFile = "MAKED - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  383. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  384. file.write(splitedDataReceived[1])
  385. else:
  386. print splitedDataReceived[1]
  387.  
  388. def F_COPYF_S(soc, file1, file2, isSave):
  389. dataToSend = r"COPYF_1\x2\x" + file1 + r"\x" + file2
  390. soc.send(dataToSend)
  391. dataReceived = soc.recv(1024)
  392. splitedDataReceived = str(dataReceived).split(r"\x")
  393. if (isSave == "YES"):
  394. nameOfTheFile = "COPYF - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  395. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  396. file.write(splitedDataReceived[1])
  397. else:
  398. print splitedDataReceived[1]
  399.  
  400. def F_EXEC_S(soc, command, isSave):
  401. dataToSend = r"EXEC_1\x1\x" + command
  402. soc.send(dataToSend)
  403. dataReceived = soc.recv(1024)
  404. splitedDataReceived = str(dataReceived).split(r"\x")
  405.  
  406. if (isSave == "YES"):
  407. nameOfTheFile = "COPYF - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  408. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  409. file.write(splitedDataReceived[1])
  410. else:
  411. print splitedDataReceived[1]
  412.  
  413. def F_DL_S(soc, command, isSave):
  414. dataToSend = r"DL_1\x1\x" + command
  415. soc.send(dataToSend)
  416. allData = ""
  417. dataReceived = str(soc.recv(1024))
  418. allData += dataReceived[9:]
  419. while not (dataReceived[-6:] == r"\y\y\y"):
  420. dataReceived = soc.recv(1024)
  421. allData += dataReceived[9:]
  422. allData = allData[:-6]
  423. with open(r"Downloads:\\" + command.split(r"\\")[-1], 'w') as file:
  424. file.write(allData)
  425.  
  426. def F_PING_S(soc, command, isSave):
  427. dataToSend = r"PING_1\x1\x" + command
  428. soc.send(dataToSend)
  429. dataReceived = soc.recv(1024)
  430. splitedDataReceived = str(dataReceived).split(r"\x")
  431.  
  432. if (isSave == "YES"):
  433. nameOfTheFile = "PING - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  434. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  435. file.write(splitedDataReceived[1])
  436. else:
  437. print splitedDataReceived[1]
  438.  
  439. def F_GET_S(soc, command, isSave):
  440. dataToSend = r"GET_1\x1\x" + command
  441. soc.send(dataToSend)
  442. dataReceived = soc.recv(1024)
  443. splitedDataReceived = str(dataReceived).split(r"\x")
  444.  
  445. if (isSave == "YES"):
  446. nameOfTheFile = "GET - " + str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  447. with open(r"Downloads:\\" + nameOfTheFile + ".txt", 'w') as file:
  448. file.write(splitedDataReceived[1])
  449. else:
  450. print splitedDataReceived[1]
  451.  
  452. def F_SCREENSHOT_S(soc, isSave):
  453. dataToSend = r"SCREENSHOT_1\x0"
  454. nameOfTheScreenshot = str(time.strftime("%d.%m.%y")) + " " + str(time.strftime("%H:%M:%S"))
  455. soc.send(dataToSend)
  456. allData = ""
  457. dataReceived = str(soc.recv(1024))
  458. allData += dataReceived[9:]
  459. while not (dataReceived[-6:] == r"\y\y\y"):
  460. dataReceived = soc.recv(1024)
  461. allData += dataReceived[9:]
  462. allData = allData[:-6]
  463. with open(r"Downloads:\\" + nameOfTheScreenshot + ".png", 'w') as file:
  464. file.write(allData)
  465.  
  466. def f_CONNECT_UPTIME_C(isSave):
  467. print "The connection is running " + str(time.time() - connection_started) + " seconds."
  468.  
  469. def f_ABOUT_C(isSave):
  470. print "We are Guy Yoffe and Omer Ben Aderet\n"
  471. print "We are in our last year in \"Magshimim\" And our project is:\n"
  472. print "Turn our hand-write into a font on the computer, and then to be able use it.\n"
  473. print "We like sports, being with friends and to programm cool stuff.\n"
  474. print "This programm contains the full Cyber meaning because\n"
  475. print "it shows what you can do, and make you thinks what else you can do with cyber\n"
  476.  
  477. def f_HELP_WITHOUT_ARGUMENT_C(isSave):
  478. print "Type commands by your choice: "
  479. print "ECHO $arg - sends the command to server, gets the same command back and print it($arg is what you want to print)"
  480. print "GIVEIP - gets the server ip"
  481. print "UPTIME - gets from the server the amount of time the server is on"
  482. print "WHOAMI - gets the username that run's the server, and the name of the operation system"
  483. print "MOVETO $arg - change the current directory($arg is the directory you want to move to)"
  484. print "RUN $arg - runs the $arg command on the server and gets the output($arg is the command you want operate)"
  485. print "PRINTF $arg - gets file data($arg the file)"
  486. print "GOAWAYF $filepath - delete the file in the path($filepath is the path of the file you want to delete)"
  487. print "GOAWAYD $dirpath - delete the directory in the path($dirpath is the path of the directory you want to delete)"
  488. print "MAKEF $filepath - creates a file in the path($filepath is the path you want to create the file in it)"
  489. print "MAKED $dirpath - creates a directory in the path($dirpath is the path you want to create the directory in it)"
  490. print "COPYF $copied_filepath $deleted_filepath - copies the content of the first file into the second file($copied_filepath is the file you want to copy his content $deleted_filepath is the file you want to move the content into him)"
  491. print "EXEX $filepath - runs the EXE file in the path on the servers computer($filepath is the path of the EXE file)"
  492. print "DL $filepath - download the file in the path($filepath is the path of the file you want to download)"
  493. print "!CONNECT_UPTIME - gets how much time the connection is on"
  494. print "!HELP - bring's up help with the programm"
  495. print "!HELP $COMMAND - bring's up help about the certain function($COMMAND is the command you want help with)"
  496. print "!ABOUT - prints information about the authors of the programm"
  497. print "!LOGOUT - end's the connection with the server"
  498. print "PING $dst - operate ping on the server($dst is where the server send's the ping to)"
  499. print "GET $website - server will send HTTTP packet to the website($website is the website to send the HTTP packet to)"
  500. print "SCREENSHOT - send's screenshot of the server to the client"
  501.  
  502. def f_HELP_WITH_ARGUMENT_C(command, isSave):
  503. if not (command in commands):
  504. print command + " Is not a command"
  505. elif(command == "ECHO"):
  506. print "ECHO: this command sends a the message contain in in the argument, gets it back from the server and print it.\n"
  507. print "Example:\n"
  508. print "[Client~$] ECHO magshimim"
  509. print "[Server~$] magshimim\n"
  510. elif(command == "GIVEIP"):
  511. print "GIVEIP: this command gets the server IPv4 addres.\n"
  512. print "Example:\n"
  513. print "[Client~$] GIVEIP"
  514. print "[Server~$] 192.168.1.1\n"
  515. elif (command == "UPTIME"):
  516. print "UPTIME: this command gets the amout of seconds that the server's on.\n"
  517. print "Example:\n"
  518. print "[Client~$] UPTIME"
  519. print "[Server~$] 45.11526\n"
  520. elif (command == "WHOAMI"):
  521. print "WHOAMI: this command tells us the current OS logged in username,\nthe underlying OS name and version, and some more basic info.\n"
  522. print "Example:\n"
  523. print "[Client~$] WHOAMI"
  524. print "[Server~$] You are username \"Moshe\", running \"Microsoft Windows 8 Pro\" installed in c:\\Windows.\n"
  525. elif (command == "MOVETO"):
  526. print "MOVETO: this command moves the current directory.\n"
  527. print "Example:\n"
  528. print "[Client~$] MOVETO C:\Windows"
  529. print "[Server~$] \n"
  530. elif (command == "RUN"):
  531. print "RUN: this command runs the command in the argument on the server's terminal or CMD.\n"
  532. print "Example:\n"
  533. print "[Client~$] RUN dir"
  534. print "[Server~$] 11/12/2016 04:16 AM <DIR> Contacts\n11/19/2016 01:47 PM <DIR> Desktop\n11/12/2016 04:16 AM <DIR> Documents\n11/19/2016 01:10 PM <DIR> Downloads\n"
  535. elif (command == "PRINTF"):
  536. print "PRINTF: this command sends a file name to the server and gets and prints his content.\n"
  537. print "Example:\n"
  538. print "[Client~$] PRINTF aa.txt"
  539. print "[Server~$] Hello there!\n"
  540. elif (command == "GOAWAYF"):
  541. print "GOAWAYF: this command removes the file that is in the argument.\n"
  542. print "Example:\n"
  543. print "[Client~$] GOAWAYF C:\\aa.txt"
  544. print "[Server~$] \n"
  545. elif (command == "GOAWAYD"):
  546. print "GOAWAYD: this command removes the directory that is in the argument.\n"
  547. print "Example:\n"
  548. print "[Client~$] GOAWAYF C:\\"
  549. print "[Server~$] \n"
  550. elif (command == "MAKEF"):
  551. print "MAKEF: this command creates a file in the path that is in the argument.\n"
  552. print "Example:\n"
  553. print "[Client~$] MAKEF C:\\aaa.txt"
  554. print "[Server~$] \n"
  555. elif (command == "MAKED"):
  556. print "MAKED: this command creates a dirctory in the path that is in the argument.\n"
  557. print "Example:\n"
  558. print "[Client~$] MAKEF C:\\a"
  559. print "[Server~$] \n"
  560. elif (command == "COPYF"):
  561. print "COPYF: this command copy's the content of the first file into the second.\n"
  562. print "Example:\n"
  563. print "[Client~$] COPYF c:\\aa.txt c:\\aaa.txt"
  564. print "[Server~$] \n"
  565. elif (command == "EXEC"):
  566. print "EXEC: this command runs the EXE file that is given in the argument.\n"
  567. print "Example:\n"
  568. print "[Client~$] EXEC C:\\a.exe"
  569. print "[Server~$] \n"
  570. elif (command == "DL"):
  571. print "DL: this command downloads the file that is given in the argument.\n"
  572. print "Example:\n"
  573. print "[Client~$] DL C:\\a.bat"
  574. print "[Server~$] a\nbbb\n"
  575. elif (command == "!CONNECT_UPTIME"):
  576. print "!CONNECT_UPTIME: this command prints how many seconds the connection is on.\n"
  577. print "Example:\n"
  578. print "[Client~$] !CONNECT_UPTIME"
  579. print "[Client~$] The connection is running 45.000012 seconds.\n"
  580. elif (command == "!HELP"):
  581. print "!HELP: this commands prints help about the programm.\n"
  582. print "Example:\n"
  583. print "[Client~$] !HELP"
  584. print "[Server~$] This programm..............................\n"
  585. elif (command == "!ABOUT"):
  586. print "!ABOUT: this command prints little bit of information on the authors of the programm.\n"
  587. print "Example:\n"
  588. print "[Client~$] !ABOUT"
  589. print "[Server~$] Me and Guy...........\n"
  590. elif (command == "!LOGOUT"):
  591. print "!LOGOUT: this command ends the connection with the server.\n"
  592. print "Example:\n"
  593. print "[Client~$] !LOGOUT"
  594. print "[Server~$] \n"
  595. elif (command == "PING"):
  596. print "PING: this command sends a ping from the server the the destination specified in the argument.\n"
  597. print "Example:\n"
  598. print "[Client~$] PING Google.com"
  599. print "[Server~$] Pinging google.com...........\n"
  600. elif (command == "GET"):
  601. print "GET: this command sends HTTP pacet from the server to where specified in the argument.\n"
  602. print "Example:\n"
  603. print "[Client~$] GET http://website.com/"
  604. print "[Server~$] \n"
  605. elif (command == "SCREENSHOT"):
  606. print "SCREENSHOT: this command gets screenshot of the server computer.\n"
  607. print "Example:\n"
  608. print "[Client~$] SCREENSHOT"
  609. print "[Server~$] data\n"
  610.  
  611. if __name__ == "__main__":
  612. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement