/PHP-magic-hashes-Open-MPI

Use Open MPI to find messages that produce SHA-1 PHP Magic Hashes. Use just CPUs, parallel distributed computing.

Primary LanguageC++GNU General Public License v3.0GPL-3.0

PHP Magic Hashes Open MPI

Copyright 2021 Maxim Masiutin maxim@masiutin.com
All rights reserved

Version 1.0.
May 28th, 2021.

An Open MPI application to look for PHP Magic Hashes using distributed computing.
It hashes multiple messages with SHA-1 until a hash is found that matches the definition of a PHP Magic Hash.
A PHP magic hash is a hash that in hexadecimal form starts with 0e and then has only decimal digits, e.g., 0e26379374770352024666148968868586665768.
See the "phpmagic_sha1.php" file for some of the messages found that produce PHP Magic Hashes if hashed with SHA-1. Here are a few of such hashes.

SHA-1 magic hashes

Decimal digits

1023456852390915	0e26379374770352024666148968868586665768

Hexadecimal lowercase

310725ea	0e27888346085153966237076252096751318517
a95156381	0e37174541203060162508519892622161096240
c38c96141	0e98310564011069505119889335007310500895
ca91af5de	00e3357955977897548139828777610074506779
d20724f23	00e9595766775400587828031383654620045131
143f9493bf	0e54784845685087958284340169639618175493
171dc478a7	0e53569150857840214604150412190235098143
1a6c63042c	0e16044724150162123254718174683432063914
1bf4f4b390	0e64007877735829643769210030396782962314
21cd3a4e9c	0e22783810467212135689194979117501964144
229ccae103	000e380536769730315799421067752156420519
23ae97d56d	0e32024188299493662816972462275961967417
23e83a9855	0e15316532641411412538267861764729506847
2983a61a7b	0e30492925184000855547435724039775513159
2cb77416fb	0e45046441046056267877397503291999851635
2f6e681271	0e08748126278286730084991358415626435095
33aeeb96dd	00e0598765937499414544128748648843824667
34002a5e42	0e58196088070507964359463330758719046049
394af00950	0e59743353781479699416013360458990350647
4367b2caa7	0e06205030705400241877848721357262808469
475c1caa6e	0e43618126125389631472554640539606740451
49fae89fcb	0e96672953502000830696460416288091075454
4ab233bd95	0e65724695766051133057377746717899841310
4d24abf3a5	0e33137854180476892531560319677033907215
4d2cfc3b15	00e9196409600571674976733499100636717182
4da1e26b9c	0e79306410033657227506247705947011167412
5020f5380c	0e64212436945016181682807002831186208575
53a8e6ba49	0e51109131383623359183925444281298632598
57b1158196	00e8142124883419459201303341422176987115
5a54a78e6b	0e46135197996625490698375113669863385092
5a9c095128	0e86827961438724897522543623467502890228
5db60567a1	0e37783422264284920479358153310137472088
6abb9d1963	0e66896005440498484589634328108375236381
6c8b64c171	0e24719101633153898806905393790735429878
6d43c1844b	0e17906403146019155409599493828600509204
6e5270765f	0e08524104113376997045252115694240324682
6ead4c9517	0e14530482825319354913894768554160922527
748c14ec33	0e55557430641255597048962459341450668982
75f4388f80	00e3532034088059351651450883957823295273
7663b71b1a	0e57451007651071778047847698852168229552
78b2eada40	0e35950808836593802311976012419713746712
7f648e7b90	000e523753008723819523453626693676134555
818f2d5506	0e57956192389567054411327591900911657297
870c456106	0e92550576435898747525984927623689858610
8edfe57b3d	0e63341609570346426852030646250061080725
8f08b4162c	00e6006722275674943569252016326834355965
917004b907	0e71465042193245854506237464151904518918
9a6ed8c246	0e42161591568602470854896747064831907484
9baaa997f8	0e18486727630173799873025996610184753091
9d3a3495cb	0e53383049850527477380345568824151428877
a7015dc958	0e87455965324229937638853538468255219693
a7dc75f3d3	0e77155023308109150667930941999248889244
a7fab6dc78	0e96767840511955823758302440992431561441
a9df9c5121	0e76908448192692414554591403202726132675
aae81f2765	0e57879374212512673468962150051972124130
b0748ade7b	0e12507025911931830520883930817889302670
b494fe6055	0e90215613852758742349717117823353835233
b4c26a9707	0e87827981072614784120993584343132793653
b73487ab78	0e33242666971435990758972431582565059597
be7761b02c	00e1763416067442196098698882310013658763
bfc3154e88	0e70961458466994771087536036127052025632
c014146bc5	0e89374158508693705672880317267344410583
c2a1eda102	0e54269769102230991130907983196189592622
c3770c2aad	0e96905448161469956256806910109353530095
c4695f7b59	0e59780480444882105438695760520395061324
c6d8f95431	0e12562994801649669448076692439024677571
c841db0bc6	0e10959255168391552298266778329381676314
ca2386932a	0e06437997191503214531162880421184247632
cb8c6553a0	0e17967733441958007467429293138747441023
d0b01d0dfa	0e21396657327757105963646214590967352064
d3cdcbaa8b	0e56070368576841064650860249015929558747
f0c65f1674	0e34549120098779598066898339524515861163
deaf1c06b19451	0e80658765566557855712019926355661294475
deaf510e35c6f1	00e4615668293684941090833020041124243672
deaf601c499e87	00e8411328422147867138673512930384153404
deafb117654bee	0e39171941011583047040807361610085646485
deafd30fc6feb0	0e24264031124789302957030631903995652149
deafc5202da7a2	0e22574972746212845925468765193060187011
deafd41f0bc84c	0e39937865511043635117582600579994539617
deafc521604e61	0e32447306368192759839665035821346326972
deaf802765c738	0e24942598631876397277689629274830758747
deaf601c499e87	00e8411328422147867138673512930384153404
deafab3000cc6e	0e43058929093673477648679400657578690954
deaf802765c738	0e24942598631876397277689629274830758747
deaf9e3aea1565	00e4647706968317634835454548443490483969
deafc93e5cbc22	0e68247202032758750933930991832491991672
deaf913f134e96	0e71116148225979207237855701219281393028
deafaf3fac6afe	0e88376352321461232898675747922119600073
deafb8501bbd67	0e65036036343706107878237145687878287322
deafa55035bc17	0e82041596333030652624874287405558144027
deaf6140980acc	0e52423475503750555846484530721944067217
deaf6f4116cbcd	0e16346553396275266338285006452657642749
deafa252bded56	0e36404265023863800397876715283625016233
deaf4f63ca9971	0e97489232707798379839161001981501994587

Hexadecimal uppercase

1B42C599AD	0e33024350315036833524054057118771347297
20EFC0B031	0e50910159675534115818641812740071128310
224613C183	0e44398097586363298591610593126047085673
263B34D8CC	0e16190004003025097507833219952259551129
2684CB8726	0e92034291993553386906871679093812059719
2E371C0521	00e1043171303727440625888490626928437060
3269026BE0	000e594315989216516931324550431073280891
34061E6E0E	0e30201942468319798750514494831095106843
356CBB130C	0e49487623182570198562896615912163083273
372828B6DF	0e91042140325384660397515276100146872409
438C0DB139	0e96671647624971276873022667125142719615
51FD972039	0e47671270821894877798140353460768954260
54D807996D	00e5355219648355394415943314774799321640
56BE839C39	0e27138394321800566142587340952777523848
5A8D1EC411	0e66306061407822443081221290924161214162
5F06FCA48D	0e60036492941048268728289467014535138238
63D28F834F	0e26671928296802710220177615963886224453
6820E1A59A	0e72744302977988087875987157485990374340
6DAF27B143	0e04834270504052247392379046353545930010
72CCED09BC	0e61684114381160446232817277593237129733
75B50CF62E	0e24948812810545167349779934220811228020
7BD24C6307	0e07478056611536100983146006887322304779
7E56613832	0e97166300011514375334769997735050073641
8351FD4D45	0e71132091334026640829936789095242101048
8470A5F419	0e28094362131741223993021625348546896088
873EE49192	0e48125287136358752732670469851359293371
8972363A94	0e73882963624013035591768879548909043164
8C70CDC547	0e43358774531554455924549710647434255620
8DF1F0B502	0e49457124601193275129502434380777263599
8F7D251F54	0e91968517130818946688789622618242041402
929CBF43EA	0e77621899524090231761903014226768598748
9847DC45A1	0e20020340814763643749249301460801224672
9CC8DA7FE8	0e59598711419314873065297863601503310880
9F6F13E678	0e26454334176092154451728902432672534691
A3F8E6ACE6	0e93223385694020737567134289381522976028
AA64C71736	0e95491167348531671380493091389052221605
ABB7E17BF8	0e98018727019820627927873407987445985524
AD1FB41FB4	0e78471221199523357468009666025753280745
ADA2665FDE	0e14151528755162989799477092241239316040
AF046CE7FD	0e90206809634710168944376723593605238319
AF250BD3B7	0e27358397577898164086837547167575061064
B288252F32	0e26493084448932886652466583783108845565
B299DF243C	0e83307391271695385892347830254182014495
B54C7FEF10	00e2278232281511959047634743687905024376
B59D394501	0e60931582010068319560195746803325940646
B907D2B47D	00e2430704397640406426337488779450055452
BEE3B5ADC5	0e56037308554988501122150650801650582785
C3011C7CA4	0e01014019281700060225840998319036510127
C4CAB81BF0	0e35140746862985877634925697779735870273
CB1EE01EE2	0e70979407066263909446712634465350680705
CBFE055069	0e16995500140186518577247384965565723405
CC32C7F285	0e62691012274047697689877944468632564051
DFC7B8D84F	0e90825507484392295565287838730407573368
E329E52FA0	0e94962594338461086012562749375680841627
E37B1E5254	0e04264720868408635036975703186799207799
E3D0719B07	0e45780832483487890188304103110985812841
E441913C60	0e23911243988885465118921650890823948550
E69105BC86	0e09167840430839042117465302143699641970
EC8C306B19	0e13572043451468038753345594146269643094
EEA16C866C	0e16027237000829248918682567855350237245
EFC5ED4F56	0e21702473188415852374901895717788553721
F675B9A60F	0e05294704769231587330847721228594416369

Hexadecimal uppercase (length=20)

DEAFC0DE1C01694010FF	0e39467675362791795113850062806237025205
DEAFC0DE1D012A1F50D0	0e69966225157021640132899757628607263285
DEAFC0DE1D014132B8B5	00e0606474060815213697774850866999297242
DEAFC0DE1D01507F049F	0e54978216091148729543393114264672267896
DEAFC0DE2001580BCE5A	0e61482378550243832993585211955048961322
DEAFC0DE430142BF494D	00e3466393188342888361869744193559994125
DEAFC0DE4A013357E5EE	00e5137783066446060895798227399603105928
DEAFC0DE560157DF0611	0e03346840107576112798805526106992806407
DEAFC0DE65013DF212D5	0e01141121988635578000305954320588798108
DEAFC0DE680153B28D55	0e66260635682766955700371013299137634677
DEAFC0DE74013BD9A934	0e57535237617061899795211060876495655671
DEAFC0DE76013BEB2491	0e00054156900346554118698221134655850952
DEAFC0DE79013A4D2379	0e41475058784305852255446149861797731570
DEAFC0DE89014BBBA903	0e15961483267193098861502466377033427890
DEAFC0DE93012E01C7FD	0e73780929169959841218788172796747421894
DEAFC0DE960151F2FCE3	0e40068541786898920851384078845667291611
DEAFC0DE9701342B214A	0e29314205767399534084492575177253424023
DEAFC0DEB40147B5488F	0e55627312110829239572856537637716796877
DEAFC0DEBE013E4DB74B	0e56418647067451265855025624436456619956
DEAFC0DEC20129522430	0e08202978877717171888383125191524129150
DEAFC0DECB015375084C	0e12709096507239750396821685588776156538
DEAFC0DEDB012485C855	00e7460991037560829133014659093202813082
DEAFC0DEE4014A3C18CF	0e08417744561792479502459780884309082981
DEAFC0DEE5014FE1582A	0e87461493363606546128079736998526535644

Lowercase letters without digits

lowercasegzmgqmx	0e46257280787231943618306073689855362607
lowercasifdvqkfr	0e11372668415308535558155136274413213182
lowercasebchqcwctky	0e63270019212961791900055698786302314274
lowercaseabcsobpkrt	0e54706107047262165256262457226759421225

Uppercase letters without digits

UPPERCASFFLIIQWR	00e0209539108131630074694125235505223102

Mixed-case letters without digits

MixedCaseERWqTVQ	0e26765837881628507475765845815158037783
MixCaseDigJiRR9d	00e6970695351422324349039381794949865825

Mixed-case letters with digits and punctuation characters

Punctu!U"F5ru	0e10005769841271999406141555258742283712
Punc!0!v!%X&H	0e46022419093253497711357929642317161144
Punc!0"5!%N/J/	0e23361421882052104970353750698818490573
Punc!0"/!"#Z"f#	0e62673103166046521233198723999648604397

Mixed-case letters with digits and punctuation characters (length=16)

Punctuati0t..jsI	0e77237948969014118794910091659528041921
Punc!0"*!"#$8!zv	0e77726009946581613829608157794165640009
UTM!1k345678fNzG	0e60098992377811189363030093264003550414
Maxim!3M3457WL8N	0e56563987203581868006812012373581596907
SI201M!2M34FUN"s	0e56771164582932122522008085807868856600
Punctuatiow$'l9X	0e16039695246683143323677708220808911326
Anastasia!$3j6CE	0e39502544098047582971721681103284862230
Anastasia"D#L3R"	0e38695756209930671587956403047252377646

SHA-224

Decimal digits

1178042717233797	0e928964351526723112553788739269038783923223407520880095
1154110493282886	0e336683500641080625765088044622710195631684919789627836
3601313439043186	0e532705245491493794814954720429835497480940353887727208
1830960243913585	0e308177680180960036581762216907627327085778441217928910

Hexadecimal lowercase

deaf420123457b55a91efc	0e100454753444829744220275905233837535766185555537937218
deaf6e012345eb24483dec	0e662600052465304194149629270511427338217613438149746597
deaf520123464aac74ced3	0e195064990651115673565349008316322342368246962501536299
deaf6401234688ca09e18d	0e285969386865294353600249290555397009707869636285369080
deaf7401234692a4b409b2	0e100107967352862760408552896740579526262653607083823505
deaf55012346e3a4db22c3	0e313341025380125043892915227789825468179418615497398072

Mixed-case letters with digits and punctuation characters

7"Z!"'ZXcym	0e438327397017329131044605404834074571667434636034800077
7#(!"JWbe&&	0e999800602605248215364506105424501005741873166835860357
7#.!$%N,mSi	0e802900385051042130587521664119734391800278594965197148
7"B!"#AryE"l	0e058341553259840085364480398068567446687374063913718383
Az0!"#+u"4)o	0e023945764059802542031764856516652021458100278855612740
Az0!T!/M"j+v	0e286753398021625469336287067231898790054157462629316278
"z!"#%!EPpzm	0e914228064358546123325423639382205708583534173614210412
7#'!"#$.3b"Rb	00e44352854908982929348215324074005718196279781969552585
Az0!"-!"/uIh.4	0e935535686278374562483257402851702629295358974432203111

Mixed-case letters with digits and punctuation characters (length=16)

Az0!M!"#$(rPrTLB	00e44602995373969921559802230997460475390751981457467310

Lowercase letters without digits

gtahleueylc	0e028942374804414919719779763451845794416362003862731183
czabexwmbivr	0e147475330983944896978659281839204115220522395134977081
ehacoqvjnmqb	0e667581767692972905138536832137761379063559688018283391
euadmluareyr	0e348478318087774591091428402576146486933831356877865792
eabctefbgpoa	0e717372291640605231879898069883156558270460274795396524
goaecekwvfec	0e916329676846171657828889334151115307430102193457370995

Lowercase letters without digits (length=16)

lowercbhkmywvrcg	0e424001036541051623441960129439086043644290251246509093
hmabcdeflpxczgym	0e002306016332170866012244558876130749408483047365238961
jjabcdefodplfozi	0e948010748457633438715637152840623338897376188523254160

Uppercase letters without digits

UPPEREIBAUEVUSYS	0e624102667555541582968619060729616544523852876008475014
UPPERGSDUJDJBTUP	00e81746209866480387167695460153455760654852742838240329

The Open MPI interface allows looking for a the PHP Magic Hash in parallel, using multiple different distributed processors.
The application should be individually compiled on each target processor to take the benefits of these particular processors (optimizations, instruction sets, SHA-1 CPU instructions, if available, etc.). You can use tools like Ansible to automate the tasks.
Although GPUs calculate hashes very quickly, this application can be useful for clusters which have no GPU but have computing time available.
For example, on 14 servers with a total of 106 cores of various processors manufactured between 2014 and 2017, some of which support SHA-1 CPU instructions and some not, with a combined Passmark CPU mark of 111706, it usually takes 2-10 seconds to find a PHP Magic Hash.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/

SHA1 implementation using the CPU instructions (sha1msg1, sha1msg2, sha1rnds4, sha1nexte) is written by Jeffrey Walton.
Taken from the Jeffrey Walton's (noloader) GitHub page at https://github.com/noloader/SHA-Intrinsics/blob/master/sha1-x86.c

SHA1 implementation using the pure C (when no the CPU is not equipped with the SHA instructions) is written by Steve Reid.
Taken from the "clibs" GitHub page at https://github.com/clibs/sha1

Compiling

Just run .\compile.sh. Modify this file accordingly, if needed.

Configuring

Look for the configuration section in the phpmagic_sha1_openmpi.cpp. You can specify whether you need a digits-only message, lowercase, uppercase, mixed-case, the mixed case with digits, or mixed case with digits and punctuation characters.
Also, look for std::string message to specify a prefix to your message. You can set an empty prefix.

Running

Use mpirun phpmagic_sha1_openmpi or the other method. You may use any way that you use to run Open MPI applications.

CPU vs GPU hashrate for SHA-1

This Open MPI application uses CPU only for hashing, not GPU. It is suitable for clusters and distributed computers with plenty of spare CPU time but no GPU.
However, please consider using Open MPI + GPU for hashing since GPU provides superior performance when it comes to hashing. You may improve this application by adding GPU support. So you will be able to use this improved application in clusters equipped with professional GPU cards for large-scale calculations.
Take the following example. My notebook comes with NVIDIA GeForce MX350 GPU, Intel Iris Plus GPU, and Intel Core i7 1065G7 (Ice Lake). According to my benchmarks, it has the following hash rate for SHA-1:

  • 2 MH/s on CPU without using SHA instructions, in single-threaded mode;
  • 8 MH/s on CPU using SHA instructions, in single-threaded mode;
  • 155.2 MH/s on the Intel Iris Plus GPU @ Accel:16 Loops:1024 Thr:1024 Vec:1;
  • 1558 MH/s on the NVIDIA GeForce MX350 GPU @ Accel:512 Loops:128 Thr:8 Vec:4.

The CPU has 4 cores, 8 threads. Even if we assume that the turbo frequency would not drop if we run 8 threads, we get a total hash rate per CPU: 8 MH/s * 8 threads = 64 MH/s for SHA-1, consuming 25 and priced US $426 in August 2019, but in reality, turbo frequency drops quickly on the notebook. In this best-case CPU-only scenario, the hash rate on this CPU is 25 times slower than on the GPU of this notebook is equipped. Even this modest GPU with which the manufacturer supplied this notebook provides 1558 MH/s for SHA-1. Imagine which hash rate may have a special-purpose professional GPU aimed for scientific fields and high-performance computing. On real servers, AMD EPYC 7401P can sustain for a long time the hash rate of 9 MH/s per hyperthreading's thread, thanks to the efficient implementation of SHA instructions, i.e., 24 cores * 2 thread * 9 MH/s = 432 MH/s per CPU with 170W power consumption and list price US $1075 (on June 2017). The AMD Ryzen 7 1700X CPU can sustain for a long time the hash rate of 12 MH/s per hyperthreading thread, i.e., 8 cores * 2 threads * 12 MH /s = 192 MH/s, consuming 95W, and priced US $399 in March 2017. Therefore, I'd be glad if you improve the Open MPI application to support GPU.