Jump to content




String Permutator (bruteforcer)


  • You cannot reply to this topic
13 replies to this topic

#1 xgaarocha

  • Members
  • 18 posts

Posted 06 January 2013 - 09:47 PM

So, I recently finished reading Digital Fortress, a book by the one and only Dan Brown. It talks about computers, bruteforcing, encripting/decripting, awesome stuff! I recomend everyone to read it, specially if you're into codding.
Anyway, so I, inspired by the awesome book, decided that I would write my own brute-forcing program! And, after almost 12 hours of coding, I did it :)

How brute-forcing works:
Imagine you want to prank a friend, but in order to do that you need to break into his locker, and don't let him notice you did . You can't ask him the padlock combination, nor you have any clue of what it is. All you know is that the combination is 4 numbers long, and goes from 1 to 9 (each number). So how do you start "cracking" the combination? You add from right to left. Like:

1111 / 1112 / 1113 / ... / 1119 / 1120 / 1121 / .. / 1198 / 1199 / 1200

By doing this you will, depending on the combination, some day/month/year find out what it is. Worst case scenario, you'd have to try 6561 combinations.

Now, you may be saying, but there are passwords that use numbers, letters, symbols, spaces and etc. I then say to you, it's the same deal. Why? Because letters, symbols and etc are just numbers with a costume. You can represent any symbol, letter, etc with a number, then it's the same deal as with the padlock. For instance, imagine you again want to prank your friend. This time, you will log-in to his Facebook, and make it look like he has attraction for people of the same sex as him. How would you do it? Assuming that your friend is dumb and only use letters on his passwords, and you know that his password is 5 characters long, you would then try out combinations this way:

AAAAA / AAAAB / AAAAC / .. / AAAAY / AAAAZ / AAABA / AAABB / .. / AAAZY / AAZZ / ABAA

It would be a little harder than cracking the padlock. If your friend only uses uppercase letters, th is 26 possible characters. Wit a 5 characters long password, in the worst case scenario it would take you 11.881.376 combinations to discover it.

How to use my code:
First, you need to know how to work with tables, loops and have a basic understanding on combinatorics.

For my code to work, it needs to know 2 things:
  • The characters that can be used on the combinations
  • The maximum length of the combinations (it will start at 1, then go to the maximum specified)
The code:
chars = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
tableName = {0}

function tableAdd (tabl)
if tabl[1] < # chars then tabl[1]=tabl[1]+1 else
for i = 1, # tabl do
if tabl[1] == # chars or tabl[i]+1 > (# chars + 1) then
tabl[i] = 1
if i+1 > # tabl then tabl[i+1] = 1 else tabl[i+1]=tabl[i+1]+1 end
end
end
end
end

function tableToChars (tabl)
local result = {0}
setmetatable(result,{__len=function() return # tabl end})
for i, v in pairs(tabl) do
result[i] = chars[v]
end
return (string.reverse(table.concat(result)))
end


Now, first you need to write your own function to try the combinations. But first you need to know what the functions do:
"tableAdd" Adds one to last index of the table. Like (0-0-1 / 0-0-9 / 0-1-0 / 0-1-1 / .. / 0-1-9 / 0-2-0 /).
"tableToChars" Converts the numbers into characters (1 = A, 2 = B... and so forth)

A simple algorithm that shows that this works is a loop.


for i = 1, 5000 do
tableAdd(tableName)
print(tableToChars(tableName))
end

It will output the first 5000 combinations, something like this:
Spoiler

Have fun :) Any doubts just ask ;) Suggestions arer welcome and appreciated.

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 06 January 2013 - 09:52 PM

Well I cant wait to see your algorithms and how effective they will be to bruteforce...

#3 xgaarocha

  • Members
  • 18 posts

Posted 06 January 2013 - 10:17 PM

There, I posted the algorithm :)

#4 xgaarocha

  • Members
  • 18 posts

Posted 07 January 2013 - 09:13 AM

Bump?

#5 anonimo182

  • Members
  • 252 posts
  • LocationIn the universe

Posted 07 January 2013 - 10:16 AM

Is not a brute forcer, but an algorithm to get sequential characters

#6 xgaarocha

  • Members
  • 18 posts

Posted 07 January 2013 - 03:22 PM

@anonimo182

That's because different systems will require different codes to input the combination and check if it's the correct one. I already did the biggest part here ;)

Note that I'm not saying you should use it to hack others computers, only if the server rules allow it (or you're with a friend, whatever).

#7 JJRcop

  • Members
  • 131 posts

Posted 07 January 2013 - 03:42 PM

How to defeat bruteforcing; have a time limit between each entry/deny other entries for a while after too many fails.

#8 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 07 January 2013 - 03:45 PM

This is a string manipulation algorithm, not a brute forcer. Be aware that if it falls under the category of "brute forcer" at some point in the future, we will be removing this as malicious code.

#9 xgaarocha

  • Members
  • 18 posts

Posted 08 January 2013 - 11:28 AM

That's the reason I only posted the combination algorithm. That and because, like I said, different systems will require different methods to input and check if the combination is a match. And I can't see how a bruteforcer is a malicious script, It only makes something that can be done by hand faster. That's why people should use long passwords with spaces and symbols, even tough, a simple password like ABCDEFG with this algorithm would take a long long time to be cracked. But I understand that some people will try it even if the server won't allow it, so I'm not posting anything further on this (algorithm wise).

#10 anonimo182

  • Members
  • 252 posts
  • LocationIn the universe

Posted 08 January 2013 - 12:04 PM

And it just crashes when trying a long word, doesn't reach to zzz

#11 xgaarocha

  • Members
  • 18 posts

Posted 11 January 2013 - 12:15 PM

That's because of computercarft's restrictions, if you run it in a lua console it will work. Putting a sleep command inside each loop will fix the issue.

#12 kornichen

  • Members
  • 220 posts
  • LocationGermany

Posted 12 January 2013 - 08:52 PM

Or if it should run faster than with a sleep in the loop use this:

o = 1
for i = 1, 5000 do
tableAdd(tableName)
print(tableToChars(tableName))
o = o + 1
if o == 10000 then
o = 1
sleep(0.00001)
end
end


#13 Zoinky

  • Members
  • 144 posts
  • LocationWellington, New Zealand

Posted 12 January 2013 - 09:26 PM

View Postkornichen, on 12 January 2013 - 08:52 PM, said:

Or if it should run faster than with a sleep in the loop use this:

o = 1
for i = 1, 5000 do
tableAdd(tableName)
print(tableToChars(tableName))
o = o + 1
if o == 10000 then
o = 1
sleep(0.00001)
end
end

sleep(0)


#14 1lann

  • Members
  • 516 posts
  • LocationSeattle

Posted 12 January 2013 - 11:24 PM

Actually the fastest would be
os.queueEvent("coroutine_trigger_event")
coroutine.yield()






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users