Advertisement
VaMinion

Stargate Brute Force

Jan 21st, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.37 KB | None | 0 0
  1. -- This program is designed to brute-force dial Stargate addresses in SGCraft.
  2. -- Why? Stargates can be randomly generated as part of your world.
  3. --   If someone doesn't map it, you have no way of knowing the gate even exists!
  4. -- This program requires Computercraft, Open Peripherals, and SGCraft to run,
  5. -- It also only brute forces one dimension at a time. Reset the variables for 6 and 7
  6.  
  7. -- Open two files.
  8. --88 File 1 - List of successful dials.
  9. --88 File 2 - 1 coordinate: most recent failed dial. Update this every time a dial fails.
  10. --  This way, the program can save its place between server restarts.
  11.  
  12. -- Initialize Chevron variable; this is what will store the address you're testing.
  13. --  When initializing, use the values from the failure file to start.
  14. --  Include a /reset switch to reset to 0,0,0,0,0,<dimension 1>,<dimension 2>
  15. -- 6, and 7 are the dimensional variables and do not change. Get these from your existing stargate.
  16.  
  17. -- Paste this line into /sgdev/sg_last_address to initialize from scratch:
  18. -- {[1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 14,[6] = 2,[7] = 1}
  19. -- Also create /sgdev/valid_addresses
  20.  
  21. -- Initialize t_chevron with default values.
  22. t_chevron = {
  23.     [1] = 1,
  24.     [2] = 1,
  25.     [3] = 1,
  26.     [4] = 1,
  27.     [5] = 14,
  28.     [6] = 2,
  29.     [7] = 1
  30. }
  31.  
  32. -- Initialize t_chevron with values from the backup file.
  33.  chevronRead = fs.open("/sgdev/sg_last_address", "r")
  34.  t_chevron = textutils.unserialize(chevronRead.readLine())
  35.  chevronRead.close()
  36.  
  37. -- Initialize alphabet table
  38. t_alpha = {
  39.     [1] = "A",
  40.     [2] =  "B",
  41.     [3] =  "C",
  42.     [4] =  "D",
  43.     [5] =  "E",
  44.     [6] =  "F",
  45.     [7] =  "G",
  46.     [8] =  "H",
  47.     [9] =  "I",
  48.     [10] =  "J",
  49.     [11] =  "K",
  50.     [12] =  "L",
  51.     [13] =  "M",
  52.     [14] =  "N",
  53.     [15] =  "O",
  54.     [16] =  "P",
  55.     [17] =  "Q",
  56.     [18] =  "R",
  57.     [19] =  "S",
  58.     [20] =  "T",
  59.     [21] =  "U",
  60.     [22] =  "V",
  61.     [23] =  "W",
  62.     [24] =  "X",
  63.     [25] =  "Y",
  64.     [26] =  "Z"
  65.     }
  66. -- First, mount the gate.
  67.  sg = peripheral.wrap("back")
  68.  
  69. -- Brute Force
  70.     -- Algorithm:
  71.     -- Set t_chevron 1, 2, 3, 4, 5, in nested loops.
  72. -- Chevron 5
  73. while t_chevron[5] <= 26 do
  74.  -- Chevron 4
  75.  while t_chevron[4] <= 26 do
  76.   -- Chevron 3
  77.   while t_chevron[3] <= 26 do
  78.    -- Chevron 2
  79.    while t_chevron[2] <= 26 do
  80.     -- Chevron 1
  81.     while t_chevron[1] <= 26 do
  82.     -- Address test
  83.      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]]
  84.      if sg.isValidAddress(testAddy) then
  85.       local sgLib = io.open("/sgdev/valid_addresses", "a")
  86.       sgLib:write("\n"..testAddy)
  87.       sgLib:flush()
  88.       sgLib:close()
  89.      end
  90.      print(testAddy)
  91.      t_chevron[1] = t_chevron[1] + 1
  92.      os.sleep(1)
  93.     end -- t_chevron[1] end
  94.     t_chevron[2] = t_chevron[2] + 1
  95.     t_chevron[1] = 1
  96.     os.sleep(0)
  97.    end -- t_chevron[2] end
  98.    t_chevron[3] = t_chevron[3] + 1
  99.    t_chevron[2] = 1
  100.    os.sleep(0)
  101.   end -- t_chevron[3] end
  102.   t_chevron[4] = t_chevron[4]  + 1
  103.   t_chevron[3] = 1
  104.    os.sleep(0)
  105.    -- Write the contents of t_chevron to a file.
  106.    print("Saving the table")
  107.    chevronBackup = fs.open("/sgdev/sg_last_address", "w")
  108.    chevronBackup.write(textutils.serialize(t_chevron))
  109.    chevronBackup.close()
  110.  end -- t_chevron[4] end
  111.  t_chevron[5] = t_chevron[5] + 1
  112.  t_chevron[4] = 1
  113.  os.sleep(0)
  114. end -- t_chevron[5] end
  115.  
  116. print("Brute force dial complete.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement