Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This is the installer
- local tArgs = {...}
- if tArgs[1] == "npc" then
- --NPC code
- local file = fs.open("Hack it-npc", "w")
- file.write([[
- --This is npc side
- --[[
- To see how to play go to : (url post)
- Hack it !
- Made by Bjornir90
- Based on hack the game
- If you want to use part of this code, ask me before doing anything please. :)
- \]\]--
- -- Definition
- local requests = {"print$", "Nfile$", "code$", "sendId$"}
- local ip = os.getComputerId()
- 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"}
- local fileT = {"little girls", "Rick", "All your base", "Sparta ?", "20 percent", "Deeeeeeerp"}
- 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()"}
- local string = stringT[1]
- local file = fileT[1]
- local datafile = stringT[1]
- local code = codeT[3]
- local ipF = 16
- -- Functions
- local function spam()
- local num = math.random(1, 4)
- if num == 1 then
- modem.transmit(actualChannel, actualChannel, "ip$"..ip.."$ print$"..string.."$")
- elseif num == 2 then
- modem.transmit(actualChannel, actualChannel, "ip$"..ip.."$ Nfile$"..file.."$ Dfile$"..datafile.."$")
- elseif num == 3 then
- modem.transmit(actualChannel, actualChannel, "ip$"..ip.."$ code$"..code.."$")
- elseif num == 4 then
- modem.transmit(actualChannel, actualChannel, "ip$"..ip.."$ sendId$"..ipF.."$ sendData$"..string.."$")
- end
- end
- local function randomize()
- local num = math.random(1,6)
- file = fileT[num]
- datafile = stringT[num]
- string = stringT[num]
- local num = math.random(1,3)
- code = codeT[num]
- local num = math.random(1, 360)
- ipF = num
- end
- while stop == "false" do
- spam()
- randomize()
- local response = {os.pullEvent("modem_message")}
- if response[4] == "#end#" then
- stop = "true"
- end
- end]])
- file.close()
- elseif tArgs[1] == "server" then
- --Server code
- local file = fs.open("Hack it - server", "w")
- file.write([[
- --This is server side please install it on a special computer with nothing else
- --[[
- To see how to play go to : (url post)
- Hack it !
- Made by Bjornir90
- Based on hack the game
- If you want to use part of this code, ask me before doing anything please.
- ]\]--
- -- Definitions
- local x, y = term.getSize()
- local midX = x/2
- local midY = y/2
- local modem = peripheral.wrap("top")
- local channel = 1
- modem.open(channel)
- IP = {} --Simply the id of computers, not local to allow hacking
- local stop = "false"
- --Functions
- local function switchChan()
- local newChannel = math.random(1, 65535)
- modem.transmit(actualChannel, actualChannel, "#/switch#")
- modem.transmit(actualChannel, actualChannel, tostring(newChannel))
- modem.close(actualChannel)
- modem.open(newChannel)
- local actualChannel = newChannel
- end
- local function protocol(msg)
- local fIPsender, sIPsender = string.find(msg, "ip$%d+$")
- local fPrint, sPrint = string.find(msg, "print$%a+$") --Search for thing to print
- local fNameFile, sNameFile = string.find(msg, "Nfile$%a+$") --Search for name of file to save
- local fDataFile, sDataFile = string.find(msg, "Dfile$%a+$") --Search for things to save into th--e file
- local fCode, sCode = string.find(msg, "code$%a+$") --Search for a command
- local fSendId, sSendId = string.find(msg, "sendId$%d+$") --Search for an id to forward to
- local fSendData, sSendData = string.find(msg, "sendData$%a+$") --Search for the data to forward to
- local fUpload, sUpload = string.find(msg, "download$%a+$") --Search for a download request
- --Check for what we must do
- local ipSender = string.sub(msg, fIPsender+3, sIPsender-1)
- for i=1, #IP do
- if ipSender = IP[i] then
- if fPrint then -- To indent
- shPrint = "true"
- end
- if fNameFile and fDataFile then
- shFile = "true"
- end
- if fCode then
- shCode = "true"
- end
- if fSendId and fSendData then
- shSend = "true"
- end
- if fUpload and sUpload then
- shUpload = "true"
- end
- if shPrint then
- dataToPrint = string.sub(msg, fPrint+6, sPrint-1)
- term.clear()
- term.setCursorPos(midX-#dataToPrint/2, midY)
- print(dataToPrint)
- end
- if shCode then
- dataToLoad = string.sub(msg, fCode+5, sCode-1)
- loadstring(dataToLoad)
- end
- if shSend then
- dataToSend = string.sub(msg, fSendData+9, sSendData-1)
- idToSend = tonumber(string.sub(msg, fSendId+7, sSendId-1))
- rednet.send(idToSend, dataToSend)
- end
- if shFile then
- dataTWF = string.sub(msg, fDataFile+6, sDataFile-1)
- nameFile = string.sub(msg, fNameFile+6, sNameFile-1)
- fileTW = fs.open(nameFile, "w")
- fileTW.write(dataTWF)
- fileTW.close()
- end
- if shUpload then
- local path = string.sub(msg, fUpload+9, sUpload-1)
- local file = fs.open("Hack_it/"..path, "r")
- local toUpload = file.readAll()
- modem.transmit(actualChannel, actualChannel, toUpload)
- file.close()
- end
- else
- local logFile = fs.open("/Hack_it/log", "a")
- logFile.write("$detected$\nIntrusion detected, system not harmed\n")
- logFile.close()
- end
- end
- --End
- --Setup with npc computer
- if not fs.exists("/Hack_it/IP") then
- modem.transmit(actualChannel, actualChannel, "#ping#")
- local messageT = {os.pullEvent("modem_message")}
- IP[1] = messageT[4]
- local ipFile = fs.open("/Hack_it/IP", "w")
- ipFile.write(IP[1])
- ipFile.close()
- else
- local ipFile = fs.open("/Hack_it/IP", "r")
- local IP[1] = ipFile.readAll()
- ipFile.close()
- end
- --Setup of game
- local file = fs.open("/Hack_it/files/firewall.bat", "w")
- file.close()
- local file = fs.open("/Hack_it/files/pictures/family.jpg", "w")
- file.close()
- local file = fs.open("/Hack_it/files/pictures/vacation.jpg", "w")
- file.close()
- local file = fs.open("/Hack_it/files/pictures/house.jpg", "w")
- file.close()
- local file = fs.open("/Hack_it/files/programs/bf3.exe", "w")
- file.close()
- local file = fs.open("/Hack_it/files/programs/origin.exe", "w")
- file.close()
- local file = fs.open("/Hack_it/files/programs/steam.exe", "w")
- file.close()
- local file = fs.open("/Hack_it/files/programs/traceur.exe", "w")
- file.close()
- local file = fs.open("/Hack_it/files/programs/VLC.exe", "w")
- file.close()
- local file = fs.open("/Hack_it/files/movies/horse_pr0n.avi", "w")
- file.close()
- local file = fs.open("/Hack_it/files/movies/child/masterPassword.txt", "w")
- file.write("I love ponys")
- file.close()
- local file = fs.open("/Hack_it/files/movies/prometheus.avi", "w")
- file.close()
- modem.transmit(actualChannel, actualChannel, "#initialize#")
- --Actual game
- while stop == "false" do
- local messageT = {os.pullEvent("modem_message")}
- if messageT[4] == "#end#" then
- stop = "true"
- end
- if messageT[4] == "won" then
- modem.open(1)
- if IP[2] then
- modem.transmit(1, 1, "true")
- else
- modem.transmit(1,1,"false")
- end
- end
- protocol(messageT[4])
- switchChan()
- if not fs.exists("/Hack_it/files/firewall.bat") then
- if not fs.exists("/Hack_it/files/programs/traceur.exe") then
- modem.transmit(actualChannel, actualChannel, "true")
- end
- end
- end
- ]])
- file.close()
- elseif tArgs[1] == "client" then
- --Client code
- local file = fs.open("Hack it", "w")
- file.write([[
- --This is client side
- --[[
- To see how to play go to : (url post)
- Hack it !
- Made by Bjornir90
- Based on hack the game
- If you want to use part of this code, ask me before doing anything please.
- ]\]--
- -- Definitions
- stop = "false"
- -- Functions
- local function won()
- local messageT = {os.pullEvent("modem_message")}
- local hasWon = messageT[4]
- if fs.exists("/Hack_it/masterPassword.txt") then
- if fs.exists("/Hack_it/bf3.exe") then
- if fs.exists("/Hack_it/prometheus.avi") then
- if hasWon == "true" then
- stop = "true"
- modem.transmit(1, 1, "won")
- shell.run("clear")
- print("Congratulation !\nYou have succefully hacked the server without being spotted !")
- end
- end
- end
- end
- return "true"
- end
- --End
- -- Some programs for help
- local fChannel = fs.open("/Hack_it/scanner", "w")
- fChannel.write([[
- --help program, use with hack it ! only
- local messageT = {os.pullEvent("modem_message")}
- if messageT[4] == "#/switch#" then
- local messageS = {os.pullEvent("modem_message")}
- local newChannel = tonumber(messageS[4])
- modem.close(actualChannel)
- modem.open(newChannel)
- actualChannel = newChannel
- end
- shell.run("Hack it")
- ]\])
- fChannel.close()
- -- Use : channel server, ip autorized, filename, new name
- local fDownloader = fs.open("/Hack_it/downloader", "w")
- fDownloader.write([[
- --Help program, use with Hack it ! only
- local tArgs = {...}
- local request = "ip$"..tArgs[2].."$ download$"..tArgs[3].."$"
- modem.transmit(tArgs[1], tArgs[1], request)
- local messageT = {os.pullEvent("modem_message")}
- local file = fs.open("/Hack_it/"..tArgs[4], "w")
- file.write(messageT[4])
- file.close()
- shell.run("Hack it")
- ]\])
- --Game
- shell.run("clear")
- while stop == "false" do
- coroutine.start(won(), shell.run("shell"))
- end
- ]])
- else
- print("Usage :\ninstaller <type of program> where type could be :\n client, server or npc")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement