Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This program is designed to brute-force dial Stargate addresses in SGCraft.
- -- Why? Stargates can be randomly generated as part of your world.
- -- If someone doesn't map it, you have no way of knowing the gate even exists!
- -- This program requires Computercraft, Open Peripherals, and SGCraft to run,
- -- It also only brute forces one dimension at a time. Reset the variables for 6 and 7
- -- Open two files.
- --88 File 1 - List of successful dials.
- --88 File 2 - 1 coordinate: most recent failed dial. Update this every time a dial fails.
- -- This way, the program can save its place between server restarts.
- -- Initialize Chevron variable; this is what will store the address you're testing.
- -- When initializing, use the values from the failure file to start.
- -- Include a /reset switch to reset to 0,0,0,0,0,<dimension 1>,<dimension 2>
- -- 6, and 7 are the dimensional variables and do not change. Get these from your existing stargate.
- -- Paste this line into /sgdev/sg_last_address to initialize from scratch:
- -- {[1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 14,[6] = 2,[7] = 1}
- -- Also create /sgdev/valid_addresses
- -- Initialize t_chevron with default values.
- t_chevron = {
- [1] = 1,
- [2] = 1,
- [3] = 1,
- [4] = 1,
- [5] = 14,
- [6] = 2,
- [7] = 1
- }
- -- Initialize t_chevron with values from the backup file.
- chevronRead = fs.open("/sgdev/sg_last_address", "r")
- t_chevron = textutils.unserialize(chevronRead.readLine())
- chevronRead.close()
- -- Initialize alphabet table
- t_alpha = {
- [1] = "A",
- [2] = "B",
- [3] = "C",
- [4] = "D",
- [5] = "E",
- [6] = "F",
- [7] = "G",
- [8] = "H",
- [9] = "I",
- [10] = "J",
- [11] = "K",
- [12] = "L",
- [13] = "M",
- [14] = "N",
- [15] = "O",
- [16] = "P",
- [17] = "Q",
- [18] = "R",
- [19] = "S",
- [20] = "T",
- [21] = "U",
- [22] = "V",
- [23] = "W",
- [24] = "X",
- [25] = "Y",
- [26] = "Z"
- }
- -- First, mount the gate.
- sg = peripheral.wrap("back")
- -- Brute Force
- -- Algorithm:
- -- Set t_chevron 1, 2, 3, 4, 5, in nested loops.
- -- Chevron 5
- while t_chevron[5] <= 26 do
- -- Chevron 4
- while t_chevron[4] <= 26 do
- -- Chevron 3
- while t_chevron[3] <= 26 do
- -- Chevron 2
- while t_chevron[2] <= 26 do
- -- Chevron 1
- while t_chevron[1] <= 26 do
- -- Address test
- local testAddy = t_alpha[t_chevron[1]]..t_alpha[t_chevron[2]]..t_alpha[t_chevron[3]]..t_alpha[t_chevron[4]]..t_alpha[t_chevron[5]]..t_alpha[t_chevron[6]]..t_alpha[t_chevron[7]]
- if sg.isValidAddress(testAddy) then
- local sgLib = io.open("/sgdev/valid_addresses", "a")
- sgLib:write("\n"..testAddy)
- sgLib:flush()
- sgLib:close()
- end
- print(testAddy)
- t_chevron[1] = t_chevron[1] + 1
- os.sleep(1)
- end -- t_chevron[1] end
- t_chevron[2] = t_chevron[2] + 1
- t_chevron[1] = 1
- os.sleep(0)
- end -- t_chevron[2] end
- t_chevron[3] = t_chevron[3] + 1
- t_chevron[2] = 1
- os.sleep(0)
- end -- t_chevron[3] end
- t_chevron[4] = t_chevron[4] + 1
- t_chevron[3] = 1
- os.sleep(0)
- -- Write the contents of t_chevron to a file.
- print("Saving the table")
- chevronBackup = fs.open("/sgdev/sg_last_address", "w")
- chevronBackup.write(textutils.serialize(t_chevron))
- chevronBackup.close()
- end -- t_chevron[4] end
- t_chevron[5] = t_chevron[5] + 1
- t_chevron[4] = 1
- os.sleep(0)
- end -- t_chevron[5] end
- print("Brute force dial complete.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement