![]() |
|
Recursive Subroutine permute | Basic Permutations - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45) +--- Forum: Grayhat • Purple Team • Hybrid Security (https://hackforums.net/forumdisplay.php?fid=449) +---- Forum: Website Hacking (https://hackforums.net/forumdisplay.php?fid=43) +---- Thread: Recursive Subroutine permute | Basic Permutations (/showthread.php?tid=3817196) |
Recursive Subroutine permute | Basic Permutations - sp3ctrum - Oct 20, 2013 [0x01] Permute() Hello HF members, I havent been on this forum in sometime but I would like to once again be active. Today I will be discussing how to do some simple permutations in perl via the recursive subroutine 'permut' from the Perl Cookbook. So I did try putting this in the cryptography section but as expected it got trashed quickly and disregarded. As for the perl section it seems pretty quite as well. But the WFH section is where I see some nice crypto based stuff being posted so might as well. c: So here we go, for those who are into cryptography I personally like to use perl to do a lot of my handy work, since the language is primarily based on text manipulation and such. [0x02] Simple Perl Script: Code #!/usr/bin/perl -wCode perl perm.pl look at me[*] Output: Code me at look[0x03] Script Functions: [*] Perl Unshift Function: Places the elements from LIST, in order, at the beginning of ARRAY. This is opposite function to shift(). [*] Return Value: Number of new elements in ARRAY. [*] Example: Code #!/usr/bin/perl -wCode Value of array is 1 2 3 4[*] Perl Splice Function: Removes the elements of ARRAY from the element OFFSET for LENGTH elements, replacing the elements removed with LIST, if specified. If LENGTH is omitted, removes everything from OFFSET onward. [*] Return Value: In scalar context undef if no elements removed In scalar context last element removed In list context empty list on failure In list context list of elements removed [*] Example: Code #!/usr/bin/perl -w[*] Output: Code Removed items: a e i[0x04] Pimping The Script & Output: Now of course, I'm sure you must have a simple understanding of the above script and how the functions work. So why not just edit it yourself and make it handle more. For example, instead of it handling words given via command line arguments, edit it to read a text file of words and shift them around to create new words. Use some bash commands to add prefixes and suffixes to each line, digits, padding techniques, bash brace expressions, use text editors such as sed, awk, gawk, nawk to edit lines. The possibilities are pretty much endless. [*] Example of above code being pipped to sed: Code perl perm.pl hey you | sed -e 's/\ /\n/g'Code you[0x05] Conclusion: Well thats my little short tutorial to string permutation in perl. Hope this helps those who are interested in this language and cryptography! :3 * - Goodies - Oct 20, 2013 Well, I can't write perl, but I can read a lot of it due to my python exprience ;) this is a great tutorial! * - sp3ctrum - Oct 21, 2013 (Oct 20, 2013 05:23 PM)Goodies Wrote: Well, I can't write perl, but I can read a lot of it due to my python exprience ;) Thanks Goodies :3 and yes this can apply in any coding language. Its also a great practice for those who are stepping into programming. * - Zhen. - Oct 21, 2013 Nice write up 3DES! Reminds me the days your tutorials were posted on Z+ Good times :p P.S I still have the DB, so no worries, I'll be uploading them in a form of Wiki anytime soon * - sp3ctrum - Oct 21, 2013 (Oct 21, 2013 01:35 PM)Zhen Wrote: Nice write up 3DES! Thanks Zero! and finally, I have been trying to contact you forever about the matter c: PM me your skype if you have one, or Im sure Ill catch you in the Dynasty IRC! * - Zixem - Oct 22, 2013 That's really good to see you again sp3ct <3 Great thread(I even didn't read, I'm sure it is) * - Im gone brah - Oct 22, 2013 A really great guide you got there. 🤝 * - Ichi - Oct 22, 2013 Oh shit is that who I think it is? Nice tut, bro. Good to see you're still around * - sp3ctrum - Oct 30, 2013 (Oct 22, 2013 08:47 PM)Ichi Wrote: Oh shit is that who I think it is? Nice tut, bro. Good to see you're still around Yes I is back at HF lol hmu on skype or something bro! Skype username: xx.des.xx Others are welcome to add me c: |