Created
June 12, 2011 02:59
-
-
Save cormacrelf/1021204 to your computer and use it in GitHub Desktop.
Ruby Vigenere Cipher cracker (password list)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EnumLike | |
@server_Symb=[: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] | |
@string_array=["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"] | |
def EnumLike.hash_of_symbols | |
server_Enum=Hash::new | |
i=1 | |
@server_Symb.each{ |e| server_Enum[e]=i; i +=1} | |
return server_Enum | |
end | |
def EnumLike.hash_of_strings | |
hash_strings = Hash::new | |
i = 1 | |
@string_array.each { |str| hash_strings[str] = i; i +=1} | |
return hash_strings | |
end | |
end | |
$symbols = EnumLike.hash_of_symbols | |
$strings = EnumLike.hash_of_strings | |
pwds = File::read("./task2passwords.txt").to_s.gsub(/\r\n/, "\n") | |
input = File::read("./task2crypt.txt").to_s.gsub(/\r|\n/, "") | |
# input = "ANPISHGHIEKIITKTUUIVXRTEPRVFLBSSTSWIJDWKZEQIDSGWSGMBWIEHNVYTUEDSRUYJIEWRLLMTGDGBGNEHQVVJIEWRPCUPUHVVSRWIQRNWXRUKDRQLVHHFFKYOILRGKVGFEHQPYDMELEITARHVIFXACEOOTQMQSBWEIOEGEJSKPYWAFLWBASXEFHBGLRVNZSGCUGIGWNOEZCVHWBSSTSWIJDWKZEQIDSGWSGMBWIEHNQETUOFNFOSWLVSTEAOKOXXZLSNLQAEWLRLTSEDEJHVVGTSEDSJKSNWRPAIAEHSWATTNOLHGMEYCSADLRVFRTBLGQFERQNAKAEPIN".gsub("\n", "") | |
def decode(input, passwordList) | |
raise ArgumentError, "Input is not a string" if input.class != String | |
raise ArgumentError, "Password list is not a string" if passwordList.class != String | |
# puts input | |
input = input.downcase! | |
puts "Decoding..." | |
pwd_chars = Array::new | |
pwds = Array::new | |
passwordList.downcase! | |
passwordList.lines.each do |line| | |
len = line.length - 1 | |
position = 0 | |
pwdcodes = Array::new | |
line.each_char do |letter| | |
position += 1 | |
letter.downcase! | |
if letter != "\n" then | |
#print $strings[letter] | |
pwdcodes << $strings[letter] | |
#if position <= len then | |
#print ";" | |
# pwdcodes << ";" | |
#end | |
#pwd_chars << $strings[letter] | |
end | |
end | |
pwd_length = pwdcodes.length | |
input_position = 0 | |
output = String::new | |
input.each_char do |in_char| | |
# print in_char | |
in_code = $strings[in_char] | |
pwd_code = pwdcodes[input_position % pwd_length] | |
out_code = in_code + 1 - pwd_code | |
$strings["e"] + 1 - $strings["s"] if input_position == 1 # => | |
while out_code <= 0 do | |
out_code = 26 + out_code | |
# puts out_code | |
end | |
while out_code > 26 do | |
out_code = out_code - 26 | |
end | |
out_char = $strings.invert[out_code] | |
input_position += 1 | |
# puts out_char | |
output << out_char | |
end | |
if output.include?("attack") then | |
30.times { print "//"} | |
print "\n" | |
puts output, "Found using #{line}" | |
return true | |
end | |
end | |
#puts pwd_chars.to_s | |
return | |
end | |
success = decode(input, pwds) | |
if success then | |
puts "Success!" | |
else | |
puts "Failure!" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ANPISHGHIEKIITKTUUIVXRTEPRVFLBSSTSWIJDWKZEQIDSGWSGMBWIEHNVY | |
TUEDSRUYJIEWRLLMTGDGBGNEHQVVJIEWRPCUPUHVVSRWIQRNWXRUKDRQLVHH | |
FFKYOILRGKVGFEHQPYDMELEITARHVIFXACEOOTQMQSBWEIOEGEJSKPY | |
WAFLWBASXEFHBGLRVNZSGCUGIGWNOEZCVHWBSSTSWIJDWKZEQIDSGWSGMB | |
WIEHNQETUOFNFOSWLVSTEAOKOXXZLSNLQAEWLRLTSEDEJHVVGTSEDSJK | |
SNWRPAIAEHSWATTNOLHGMEYCSADLRVFRTBLGQFERQNAKAEPIN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aardvark | |
abductor | |
abnormalities | |
abortive | |
abruptly | |
absoluteness | |
abstract | |
abutters | |
accentuate | |
accessing | |
accolade | |
accomplishers | |
accounted | |
accumulator | |
achievements | |
acoustically | |
acquisitive | |
activations | |
acuteness | |
additive | |
adequately | |
adjourns | |
adjustors | |
admirations | |
admonition | |
adulterate | |
advantaged | |
advertised | |
advocates | |
affirmative | |
affronts | |
agglomerated | |
aggregations | |
agonized | |
airfoils | |
alarmist | |
algorithmically | |
alleging | |
alligators | |
allowable | |
alphabetics | |
alternative | |
amalgams | |
ambitions | |
amenities | |
ampersands | |
amputates | |
analysts | |
anastomoses | |
anecdotal | |
anhydrous | |
annihilates | |
annoyers | |
anonymity | |
anteaters | |
antibiotics | |
antinomian | |
antislavery | |
aperiodicity | |
apostolic | |
appealingly | |
appendicitis | |
application | |
apportioning | |
appreciations | |
approached | |
approvers | |
arachnid | |
archdiocese | |
archives | |
arithmetical | |
arraigns | |
arrogated | |
articulate | |
artillerist | |
ascertains | |
aspirations | |
assemblage | |
assertiveness | |
assimilated | |
associatively | |
asterisk | |
astronomers | |
atemporal | |
atrocity | |
attainers | |
attentionality | |
attracting | |
atypically | |
auditioned | |
auspiciously | |
authority | |
autocratic | |
automatic | |
autumnal | |
aversions | |
awkwardly | |
backaches | |
backplanes | |
backtracked | |
baffling | |
ballgown | |
bandstand | |
banquets | |
barbecued | |
barnyards | |
baseball | |
bathroom | |
beachhead | |
beautifiers | |
bedraggle | |
befouling | |
beguiled | |
belatedly | |
belligerently | |
beneficence | |
bequests | |
besmirching | |
bettering | |
bibliographic | |
biennium | |
billowed | |
blackening | |
bladders | |
blaspheming | |
blighted | |
blockade | |
bloodstream | |
bluestocking | |
boasters | |
bodybuilding | |
bonanzas | |
boomerangs | |
borrowed | |
bowdlerized | |
brainstem | |
braveness | |
breakdown | |
breathed | |
bridegroom | |
bristling | |
broadness | |
brothels | |
brushlike | |
budgeting | |
bulletins | |
bunkmates | |
bushwhacks | |
butternut | |
cabbages | |
calendars | |
cameramen | |
candidacy | |
canonicalization | |
capaciousness | |
capitals | |
capturing | |
carcinoma | |
carnation | |
cartridge | |
cataclysmic | |
categorized | |
causation | |
ceaselessly | |
cemetery | |
certainty | |
chairwoman | |
championships | |
chanting | |
charcoal | |
chastely | |
cheapness | |
cheerfully | |
chestnut | |
chimpanzee | |
choosers | |
chronicler | |
churchwoman | |
circulate | |
circumspectly | |
civilians | |
clamping | |
classifier | |
cleanses | |
cleverness | |
clippings | |
clothing | |
clutches | |
coatings | |
coefficient | |
cognitively | |
colander | |
collaring | |
collision | |
colonizing | |
combinatorially | |
comforted | |
commemorates | |
commenting | |
committeewomen | |
communicant | |
commutes | |
comparatively | |
compatible | |
competition | |
complaints | |
compliance | |
componentry | |
comprehending | |
compromiser | |
computerized | |
conceded | |
conceptions | |
conciliatory | |
concurred | |
condescend | |
conductivity | |
confessions | |
configures | |
conflict | |
confronters | |
congratulations | |
conjectures | |
connectionless | |
conquering | |
consented | |
conservator | |
consistently | |
consortium | |
constituencies | |
construct | |
consultations | |
contacts | |
contemplation | |
contents | |
contingents | |
contraception | |
contrapositive | |
contributors | |
controversy | |
convergence | |
convertible | |
convincingly | |
cooperators | |
cordially | |
corporals | |
correlates | |
corroborates | |
costumed | |
councilwomen | |
countered | |
counterrevolution | |
courteous | |
coverage | |
crackles | |
crawling | |
credible | |
crestfallen | |
criticized | |
crossroad | |
crumbled | |
crutches | |
cufflink | |
cultures | |
curricular | |
customary | |
cycloidal | |
dandelion | |
daydream | |
deallocating | |
decadently | |
decennial | |
deciphered | |
declaring | |
decomposition | |
decrement | |
deemphasize | |
defender | |
defiantly | |
deformities | |
delegate | |
delicacies | |
delineated | |
delusions | |
demolishes | |
demultiplexer | |
denoting | |
departures | |
deplores | |
depreciate | |
deregulate | |
describe | |
deserves | |
desiring | |
despotic | |
destructiveness | |
detection | |
determinative | |
devastate | |
devising | |
diagnoses | |
dialysis | |
dictators | |
differentiating | |
diffusions | |
digression | |
dimensions | |
direction | |
disambiguated | |
disarmed | |
discarding | |
disclaim | |
discontinuance | |
discoverer | |
discriminating | |
disfigured | |
disheartening | |
disinterested | |
dislocation | |
dismounts | |
dispatchers | |
displaced | |
disposing | |
disregard | |
dissemination | |
dissociate | |
distemper | |
distinguishes | |
distributing | |
divergences | |
dividends | |
dockyard | |
dodecahedron | |
dominates | |
doubleton | |
download | |
draftsman | |
drawings | |
drifters | |
druggist | |
duplicated | |
dwindling | |
earnestness | |
eastwards | |
economically | |
educating | |
efficient | |
ejaculate | |
election | |
electrocuting | |
elegance | |
eliminating | |
elucidation | |
embellishes | |
emergence | |
emperors | |
employments | |
encamped | |
encloses | |
encouragingly | |
endeavored | |
enervate | |
engineers | |
enlargement | |
enormous | |
ensnared | |
enthusiasm | |
entrenched | |
enveloper | |
epidemic | |
equalization | |
equipped | |
erringly | |
especially | |
estimates | |
evaluate | |
eventual | |
evolutes | |
exaggeration | |
excavation | |
excesses | |
exclaimers | |
excreted | |
executives | |
exerting | |
exigency | |
expansion | |
expeditions | |
experimentations | |
expletive | |
explores | |
exporters | |
expressive | |
extensively | |
extorted | |
extrapolation | |
eyeglasses | |
facsimiles | |
faithfulness | |
familiarization | |
farewell | |
fashions | |
fattening | |
featherer | |
felicity | |
fertilize | |
fickleness | |
fighters | |
finalized | |
finished | |
fireworks | |
flabbergast | |
flattering | |
flexibly | |
flopping | |
fluctuating | |
followers | |
footprints | |
forecasts | |
foresight | |
forfeiture | |
formalization | |
formulated | |
fortitude | |
foundered | |
fracturing | |
fraternally | |
frequencies | |
fretfulness | |
frightfulness | |
fruition | |
functionalities | |
furiously | |
gadgetry | |
gangsters | |
gathered | |
generalizing | |
gentleman | |
geometrically | |
gigabits | |
goldenrod | |
grabbers | |
grafting | |
grandparent | |
graspingly | |
graveyard | |
grenades | |
groaning | |
gruesome | |
guessing | |
gymnastics | |
hallowed | |
handiest | |
haphazardly | |
hardship | |
harshness | |
headgear | |
hearings | |
heighten | |
hemostat | |
heritages | |
heterosexual | |
highlight | |
hindsight | |
hoarseness | |
homemaker | |
homogeneous | |
honorably | |
horrible | |
hospitalized | |
housekeeping | |
humidifier | |
hundreds | |
hydrogen | |
hypothetical | |
identical | |
idolatry | |
illuminating | |
imaginably | |
immaterial | |
imminently | |
impartial | |
imperative | |
impersonally | |
implement | |
implored | |
impotence | |
impressionable | |
improper | |
impulsion | |
inadvertent | |
incandescent | |
incidentally | |
inclusions | |
incompletely | |
inconsistently | |
increase | |
incubating | |
indelible | |
indicates | |
indignity | |
individuality | |
inductance | |
industrialized | |
inequity | |
infallibility | |
inferior | |
infinitude | |
influence | |
infrastructure | |
ingenuous | |
inheriting | |
inimical | |
initiations | |
innocence | |
inorganic | |
inscrutable | |
insignificance | |
insomnia | |
installers | |
instigating | |
institutions | |
instruments | |
insurmountable | |
intellectually | |
intensity | |
intercepting | |
interconnect | |
interfaced | |
interlaces | |
intermix | |
interpolated | |
interrelate | |
interruptive | |
intervene | |
intimately | |
intractable | |
intriguing | |
intrusion | |
invalidity | |
inventories | |
investigative | |
invoiced | |
irrationally | |
irresistible | |
irritates | |
itemizations | |
javelins | |
journalists | |
judicious | |
justifying | |
kidnappings | |
kitchenette | |
knuckles | |
lacquered | |
landscape | |
latitudes | |
laureate | |
leaflets | |
leftover | |
legislature | |
letterhead | |
liberalized | |
licensing | |
lighters | |
limestone | |
linguist | |
literalness | |
loadings | |
lounging | |
lumbered | |
machinery | |
magnetically | |
mainframes | |
maladies | |
management | |
manifest | |
manipulatory | |
mappings | |
marketplaces | |
masculinity | |
masterpiece | |
maternal | |
maturing | |
meaningfully | |
mechanism | |
medicines | |
megawatt | |
memoranda | |
mentalities | |
methodical | |
microcode | |
microphones | |
microwave | |
mightiest | |
milliammeter | |
mimicking | |
minimizations | |
minutemen | |
misconception | |
mismanagement | |
misspelling | |
misunderstood | |
moderated | |
modifies | |
molecule | |
mongoose | |
monopolies | |
monument | |
morphological | |
mouthful | |
multilayer | |
multiplicity | |
mumbling | |
musculature | |
mutation | |
mythologies | |
narrative | |
nationals | |
navigators | |
needless | |
negotiated | |
neuritis | |
newsletters | |
nihilism | |
nominating | |
nondeterministic | |
nonmaskable | |
nonspecialist | |
normalizes | |
notarize | |
notifies | |
nullifying | |
nutrition | |
objector | |
obscurely | |
occupancy | |
oddities | |
officials | |
omnipotent | |
operationally | |
opposites | |
optimized | |
orchestrate | |
originating | |
oscillated | |
ourselves | |
outlawing | |
outsiders | |
overcame | |
overflow | |
overlaps | |
overprints | |
overshoot | |
overtakes | |
overwhelms | |
packager | |
paleness | |
pantheist | |
paradigms | |
parallelogram | |
paramount | |
pardoned | |
parliament | |
participle | |
passenger | |
patenter | |
patriarchy | |
penguins | |
perceive | |
percussion | |
performs | |
perished | |
permitted | |
perpetually | |
persevering | |
personify | |
pertained | |
pestilence | |
phenomena | |
philosophizing | |
photodiode | |
physician | |
picojoule | |
pilferage | |
pinwheel | |
pityingly | |
planarity | |
plasters | |
playmate | |
plenteous | |
plunging | |
poisoning | |
politician | |
pondered | |
populousness | |
portraits | |
possessions | |
postmortem | |
potentates | |
powering | |
praiseworthy | |
precaution | |
precipitately | |
preconceive | |
predetermination | |
predicts | |
prefabricate | |
preoccupied | |
preprocessors | |
presented | |
pressing | |
presupposed | |
prevailed | |
pricking | |
principles | |
proceeding | |
procrastinated | |
production | |
proficiency | |
prognosis | |
prohibitions | |
proliferation | |
promoting | |
pronouncements | |
propensity | |
proprietor | |
prosodic | |
prostitute | |
protested | |
protrusions | |
provisionally | |
psilocybin | |
psychosomatic | |
puddling | |
punitive | |
purporters | |
puzzlings | |
quagmire | |
quantifiers | |
quarries | |
questers | |
quicksand | |
racetrack | |
radiology | |
ramification | |
raptures | |
rationally | |
reacting | |
readying | |
reappeared | |
reassemble | |
rebelled | |
rebutted | |
recaptures | |
receptivity | |
recitation | |
reclassify | |
recollections | |
recomputing | |
recoverable | |
recuperate | |
redeclared | |
redirecting | |
reduction | |
reestablished | |
referenda | |
reflection | |
reformed | |
refreshingly | |
regenerating | |
regressing | |
regulations | |
relative | |
relentless | |
relinquish | |
remainder | |
reminders | |
remotest | |
renovate | |
repaired | |
repentance | |
replacer | |
reporter | |
representatives | |
reproached | |
reptiles | |
reputation | |
reroutes | |
resembling | |
residentially | |
resistors | |
resourceful | |
responded | |
restates | |
restrainers | |
resulted | |
retailers | |
reticulated | |
retroactive | |
revealing | |
reversely | |
rickshaw | |
rightmost | |
roadster | |
rosebush | |
roundworm | |
rumbling | |
sacrificed | |
sagacious | |
salamander | |
sanctioning | |
satellites | |
savaging | |
scanners | |
scheduler | |
schooler | |
scolding | |
scrambler | |
screeching | |
scrupulously | |
seahorse | |
seasonings | |
secretion | |
seducing | |
seizures | |
semantics | |
sensational | |
sentential | |
sequence | |
servings | |
sharpest | |
sheriffs | |
shippers | |
shootings | |
shortish | |
shredder | |
shuffled | |
sidelights | |
significance | |
silliness | |
simplifiers | |
sinfulness | |
situated | |
sketchily | |
skulking | |
slaughtered | |
slightness | |
slumming | |
smokestack | |
snapdragon | |
snooping | |
socialist | |
solidify | |
sometimes | |
sorrowfully | |
sovereign | |
sparsest | |
specifiable | |
spectacularly | |
speculation | |
spherically | |
spiteful | |
splitting | |
sportingly | |
sprightly | |
spurious | |
squeaked | |
stairways | |
stanchion | |
starling | |
stationing | |
steadfastly | |
steepest | |
stereotypical | |
stiffens | |
stinging | |
stockbroker | |
stopwatch | |
straight | |
stranger | |
stratifies | |
striving | |
struggled | |
stupefying | |
subcomponents | |
subfield | |
sublimation | |
submultiplexed | |
subroutine | |
subsequences | |
subspaces | |
substituting | |
subtlest | |
subverter | |
suffocates | |
suitably | |
summations | |
superbly | |
superintendents | |
supersede | |
supplants | |
supportively | |
surfaced | |
surprises | |
survived | |
suspiciously | |
sweatshirt | |
swimmers | |
sycophantic | |
symmetry | |
synaptic | |
synergistic | |
tabulations | |
tantamount | |
tautologies | |
technically | |
telegraph | |
telescope | |
temperature | |
tendency | |
terminator | |
terrorism | |
testimony | |
theatricals | |
theorizing | |
thimbles | |
thoughtless | |
threshold | |
thumbing | |
tightens | |
totallers | |
townships | |
trafficking | |
transact | |
transcriptions | |
transformers | |
transitive | |
transmittal | |
transponders | |
traveled | |
treasures | |
trespasser | |
triggered | |
triumphed | |
troubling | |
truthfulness | |
twenties | |
typifies | |
unaccountable | |
unanswered | |
unbiased | |
uncleanly | |
unconstrained | |
undecided | |
undergoing | |
underpinning | |
undertaker | |
undeveloped | |
unidirectionally | |
uninteresting | |
universe | |
unlimited | |
unnaturally | |
unplanned | |
unresponsive | |
unsettling | |
unsurprisingly | |
unusually | |
unwrapped | |
uprooted | |
utilized | |
vagabonds | |
vandalized | |
variances | |
vegetating | |
ventricles | |
verifies | |
vibrated | |
videotape | |
villagers | |
visualized | |
voltages | |
waitresses | |
warningly | |
watchwords | |
wearable | |
westerner | |
whippers | |
whiteners | |
wickedness | |
wiretapping | |
withstand | |
woodcocks | |
workshop | |
worthwhileness | |
wretchedness | |
yellowed | |
zoologically |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Made for the UNSW ProgComp - http://www.computing.unsw.edu.au/progcomp/
Run the ruby within the folder, and: