So basically the problem is that this pattern detect nothing, so what is wrong ?
Thanks you :)/>/>
--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.
fs.makeDir("hack_it")
fs.makeDir("hack_it/files")
fs.makeDir("hack_it/files/movies")
fs.makeDir("hack_it/files/pictures")
fs.makeDir("hack_it/files/movies/child")
fs.makeDir("hack_it/files/programs")
-- 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"
local actualChannel = 1
--Functions
local function switchChan()
local newChannel = math.random(1, 65535)
modem.transmit(actualChannel, actualChannel, "#switch#")
modem.transmit(actualChannel, actualChannel, tostring(newChannel))
print("Sent request to change channel to "..newChannel)
modem.closeAll()
modem.open(newChannel)
local actualChannel = newChannel
end
--HERE __________________________________________
local function protocol(msg)
print("Started check for BRP request") --Print it
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
print(fIPsender) --Print a blank line
sleep(2)
if fIPsender then
print("Found ip of sender") --It didn't print that
local ipSender = string.sub(msg, fIPsender+3, sIPsender-1)
for i=1, #IP do
if ipSender == IP[i] then
print("Request from"..ipSender)
if fPrint then
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
end
--End
--Actual game
while stop == "false" do
local messageT = {os.pullEvent("modem_message")}
if messageT[5] == "#end#" then
stop = "true"
end
if messageT[5] == "won" then
modem.open(1)
if IP[2] then
modem.transmit(1, 1, "true")
else
modem.transmit(1,1,"false")
end
end
protocol(messageT[5])
print("Received message :"..messageT[5])
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