Advertisement
Bjornir90

Hack it ! - installer

Jul 16th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.85 KB | None | 0 0
  1.  
  2. --This is the installer
  3.  
  4. local tArgs = {...}
  5. if tArgs[1] == "npc" then
  6.  
  7. --NPC code
  8. local file = fs.open("Hack it-npc", "w")
  9. file.write([[
  10. --This is npc side
  11.  
  12. --[[
  13. To see how to play go to : (url post)
  14. Hack it !
  15. Made by Bjornir90
  16. Based on hack the game
  17. If you want to use part of this code, ask me before doing anything please. :)
  18. \]\]--
  19.  
  20. -- Definition
  21. local requests = {"print$", "Nfile$", "code$", "sendId$"}
  22. local ip = os.getComputerId()
  23. local stringT = {"I love little girls they make me feel so good", "Never gonna give you up", "All your bases are belong to us", "Madness ? This is sparta !", "It needs to be about 20 percent cooler", "derp derp derpy derp derping derpy derp"}
  24. local fileT = {"little girls", "Rick", "All your base", "Sparta ?", "20 percent", "Deeeeeeerp"}
  25. local codeT = {"local file = fs.open(\"Hack_it/files/movies/horse_pr0n\", \"r\") local data = file.readAll() file.close() modem.transmit(actualChannel, actualChannel, data)", "print(\"hello\")", "local file = fs.open(\"/Hack_it/files/movies/horse_pr0n2\", \"w\") file.write(\"Oh yes, ho yes\") file.close()"}
  26. local string = stringT[1]
  27. local file = fileT[1]
  28. local datafile = stringT[1]
  29. local code = codeT[3]
  30. local ipF = 16
  31. -- Functions
  32. local function spam()
  33.  local num = math.random(1, 4)
  34.  if num == 1 then
  35.   modem.transmit(actualChannel, actualChannel, "ip$"..ip.."$ print$"..string.."$")
  36.  elseif num == 2 then
  37.   modem.transmit(actualChannel, actualChannel, "ip$"..ip.."$ Nfile$"..file.."$ Dfile$"..datafile.."$")
  38.  elseif num == 3 then
  39.   modem.transmit(actualChannel, actualChannel, "ip$"..ip.."$ code$"..code.."$")
  40.  elseif num == 4 then
  41.   modem.transmit(actualChannel, actualChannel, "ip$"..ip.."$ sendId$"..ipF.."$ sendData$"..string.."$")
  42.  end
  43. end
  44.  
  45. local function randomize()
  46.  local num = math.random(1,6)
  47.  file = fileT[num]
  48.  datafile = stringT[num]
  49.  string = stringT[num]
  50.  local num = math.random(1,3)
  51.  code = codeT[num]
  52.  local num = math.random(1, 360)
  53.  ipF = num
  54. end
  55.  
  56.  
  57. while stop == "false" do
  58.  spam()
  59.  randomize()
  60.  local response = {os.pullEvent("modem_message")}
  61.   if response[4] == "#end#" then
  62.    stop = "true"
  63.   end
  64. end]])
  65. file.close()
  66.  
  67. elseif tArgs[1] == "server" then
  68.  
  69. --Server code
  70.  
  71. local file = fs.open("Hack it - server", "w")
  72. file.write([[
  73. --This is server side please install it on a special computer with nothing else
  74.  
  75. --[[
  76. To see how to play go to : (url post)
  77. Hack it !
  78. Made by Bjornir90
  79. Based on hack the game
  80. If you want to use part of this code, ask me before doing anything please.
  81. ]\]--
  82.  
  83.  
  84. -- Definitions
  85. local x, y = term.getSize()
  86. local midX = x/2
  87. local midY = y/2
  88. local modem = peripheral.wrap("top")
  89. local channel = 1
  90. modem.open(channel)
  91. IP = {} --Simply the id of computers, not local to allow hacking
  92. local stop = "false"
  93.  
  94.  
  95.  
  96. --Functions
  97. local function switchChan()
  98. local newChannel = math.random(1, 65535)
  99. modem.transmit(actualChannel, actualChannel, "#/switch#")
  100. modem.transmit(actualChannel, actualChannel, tostring(newChannel))
  101. modem.close(actualChannel)
  102. modem.open(newChannel)
  103. local actualChannel = newChannel
  104. end
  105.  
  106.  
  107. local function protocol(msg)
  108.  local fIPsender, sIPsender = string.find(msg, "ip$%d+$")
  109.  local fPrint, sPrint = string.find(msg, "print$%a+$") --Search for thing to print
  110.  local fNameFile, sNameFile = string.find(msg, "Nfile$%a+$") --Search for name of file to save
  111.  local fDataFile, sDataFile = string.find(msg, "Dfile$%a+$") --Search for things to save into th--e file
  112.  local fCode, sCode = string.find(msg, "code$%a+$") --Search for a command
  113.  local fSendId, sSendId = string.find(msg, "sendId$%d+$") --Search for an id to forward to
  114.  local fSendData, sSendData = string.find(msg, "sendData$%a+$") --Search for the data to forward to
  115.  local fUpload, sUpload = string.find(msg, "download$%a+$") --Search for a download request
  116. --Check for what we must do
  117.  
  118.  local ipSender = string.sub(msg, fIPsender+3, sIPsender-1)
  119.  for i=1, #IP do
  120.   if ipSender = IP[i] then
  121.  if fPrint then            -- To indent
  122.   shPrint = "true"
  123.  end
  124.  if fNameFile and fDataFile then
  125.   shFile = "true"
  126.  end
  127.  if fCode then
  128.   shCode = "true"
  129.  end
  130.  if fSendId and fSendData  then
  131.   shSend = "true"
  132.  end
  133.  if fUpload and sUpload then
  134.   shUpload = "true"
  135.  end
  136.  
  137.  if shPrint then
  138.   dataToPrint = string.sub(msg, fPrint+6, sPrint-1)
  139.   term.clear()
  140.   term.setCursorPos(midX-#dataToPrint/2, midY)
  141.   print(dataToPrint)
  142.  end
  143.  if shCode then
  144.   dataToLoad = string.sub(msg, fCode+5, sCode-1)
  145.   loadstring(dataToLoad)
  146.  end
  147.  if shSend then
  148.   dataToSend = string.sub(msg, fSendData+9, sSendData-1)
  149.   idToSend = tonumber(string.sub(msg, fSendId+7, sSendId-1))
  150.   rednet.send(idToSend, dataToSend)
  151.  end
  152.  if shFile then
  153.   dataTWF = string.sub(msg, fDataFile+6, sDataFile-1)
  154.   nameFile = string.sub(msg, fNameFile+6, sNameFile-1)
  155.   fileTW = fs.open(nameFile, "w")
  156.   fileTW.write(dataTWF)
  157.   fileTW.close()
  158.  end
  159.  if shUpload then
  160.   local path = string.sub(msg, fUpload+9, sUpload-1)
  161.   local file = fs.open("Hack_it/"..path, "r")
  162.   local toUpload = file.readAll()
  163.   modem.transmit(actualChannel, actualChannel, toUpload)
  164.   file.close()
  165.  end
  166.  else
  167.   local logFile = fs.open("/Hack_it/log", "a")
  168.   logFile.write("$detected$\nIntrusion detected, system not harmed\n")
  169.   logFile.close()
  170.  end
  171. end
  172.  
  173. --End
  174.  
  175.  
  176. --Setup with npc computer
  177. if not fs.exists("/Hack_it/IP") then
  178. modem.transmit(actualChannel, actualChannel, "#ping#")
  179. local messageT = {os.pullEvent("modem_message")}
  180. IP[1] = messageT[4]
  181. local ipFile = fs.open("/Hack_it/IP", "w")
  182. ipFile.write(IP[1])
  183. ipFile.close()
  184. else
  185. local ipFile = fs.open("/Hack_it/IP", "r")
  186. local IP[1] = ipFile.readAll()
  187. ipFile.close()
  188. end
  189.  
  190.  
  191. --Setup of game
  192. local file = fs.open("/Hack_it/files/firewall.bat", "w")
  193. file.close()
  194. local file = fs.open("/Hack_it/files/pictures/family.jpg", "w")
  195. file.close()
  196. local file = fs.open("/Hack_it/files/pictures/vacation.jpg", "w")
  197. file.close()
  198. local file = fs.open("/Hack_it/files/pictures/house.jpg", "w")
  199. file.close()
  200. local file = fs.open("/Hack_it/files/programs/bf3.exe", "w")
  201. file.close()
  202. local file = fs.open("/Hack_it/files/programs/origin.exe", "w")
  203. file.close()
  204. local file = fs.open("/Hack_it/files/programs/steam.exe", "w")
  205. file.close()
  206. local file = fs.open("/Hack_it/files/programs/traceur.exe", "w")
  207. file.close()
  208. local file = fs.open("/Hack_it/files/programs/VLC.exe", "w")
  209. file.close()
  210. local file = fs.open("/Hack_it/files/movies/horse_pr0n.avi", "w")
  211. file.close()
  212. local file = fs.open("/Hack_it/files/movies/child/masterPassword.txt", "w")
  213. file.write("I love ponys")
  214. file.close()
  215. local file = fs.open("/Hack_it/files/movies/prometheus.avi", "w")
  216. file.close()
  217. modem.transmit(actualChannel, actualChannel, "#initialize#")
  218.  
  219.  
  220. --Actual game
  221. while stop == "false" do
  222.  local messageT = {os.pullEvent("modem_message")}
  223.  if messageT[4] == "#end#" then
  224.   stop = "true"
  225.  end
  226.  if messageT[4] == "won" then
  227.   modem.open(1)
  228.   if IP[2] then
  229.   modem.transmit(1, 1, "true")
  230.   else
  231.   modem.transmit(1,1,"false")
  232.   end
  233.  end
  234.  protocol(messageT[4])
  235.  switchChan()
  236.  if not fs.exists("/Hack_it/files/firewall.bat") then
  237.   if not fs.exists("/Hack_it/files/programs/traceur.exe") then
  238.    modem.transmit(actualChannel, actualChannel, "true")
  239.   end
  240.  end
  241. end
  242. ]])
  243. file.close()
  244.  
  245. elseif tArgs[1] == "client" then
  246.  
  247.  
  248. --Client code
  249.  
  250. local file = fs.open("Hack it", "w")
  251. file.write([[
  252. --This is client side
  253.  
  254. --[[
  255. To see how to play go to : (url post)
  256. Hack it !
  257. Made by Bjornir90
  258. Based on hack the game
  259. If you want to use part of this code, ask me before doing anything please.
  260. ]\]--
  261.  
  262.  
  263. -- Definitions
  264. stop = "false"
  265.  
  266.  
  267. -- Functions
  268. local function won()
  269. local messageT = {os.pullEvent("modem_message")}
  270. local hasWon = messageT[4]
  271.  if fs.exists("/Hack_it/masterPassword.txt") then
  272.   if fs.exists("/Hack_it/bf3.exe") then
  273.    if fs.exists("/Hack_it/prometheus.avi") then
  274.     if hasWon == "true" then
  275.      stop = "true"
  276.      modem.transmit(1, 1, "won")
  277.      shell.run("clear")
  278.      print("Congratulation !\nYou have succefully hacked the server without being spotted !")
  279.     end
  280.    end
  281.   end
  282.  end
  283.  return "true"
  284. end
  285.    
  286. --End
  287. -- Some programs for help
  288. local fChannel = fs.open("/Hack_it/scanner", "w")
  289. fChannel.write([[
  290. --help program, use with hack it ! only
  291.  
  292.  local messageT = {os.pullEvent("modem_message")}
  293.  if messageT[4] == "#/switch#" then
  294.   local messageS = {os.pullEvent("modem_message")}
  295.   local newChannel = tonumber(messageS[4])
  296.   modem.close(actualChannel)
  297.   modem.open(newChannel)
  298.   actualChannel = newChannel
  299.  end
  300.  shell.run("Hack it")
  301. ]\])
  302. fChannel.close()
  303.  
  304. -- Use : channel server, ip autorized, filename, new name
  305. local fDownloader = fs.open("/Hack_it/downloader", "w")
  306. fDownloader.write([[
  307. --Help program, use with Hack it ! only
  308. local tArgs = {...}
  309. local request = "ip$"..tArgs[2].."$ download$"..tArgs[3].."$"
  310. modem.transmit(tArgs[1], tArgs[1], request)
  311. local messageT = {os.pullEvent("modem_message")}
  312. local file = fs.open("/Hack_it/"..tArgs[4], "w")
  313. file.write(messageT[4])
  314. file.close()
  315. shell.run("Hack it")
  316. ]\])
  317.  
  318.  
  319. --Game
  320. shell.run("clear")
  321. while stop == "false" do
  322.  coroutine.start(won(), shell.run("shell"))
  323. end
  324. ]])
  325. else
  326.  print("Usage :\ninstaller <type of program> where type could be :\n client, server or npc")
  327. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement