Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.29 KB | None | 0 0
  1. +----------------------------------------------------------------------------------------+
  2. | |
  3. | PPPPPPPPPPPPPPPPP lllllll 555555555555555555 |
  4. | P::::::::::::::::P l:::::l 5::::::::::::::::5 |
  5. | P::::::PPPPPP:::::P l:::::l 5::::::::::::::::5 |
  6. | PP:::::P P:::::P l:::::l 5:::::555555555555 |
  7. | P::::P P:::::P eeeeeeeeeeee rrrrr rrrrrrrrr l::::l 5:::::5 |
  8. | P::::P P:::::Pee::::::::::::ee r::::rrr:::::::::r l::::l 5:::::5 |
  9. | P::::PPPPPP:::::Pe::::::eeeee:::::eer:::::::::::::::::r l::::l 5:::::5555555555 |
  10. | P:::::::::::::PPe::::::e e:::::err::::::rrrrr::::::rl::::l 5:::::::::::::::5 |
  11. | P::::PPPPPPPPP e:::::::eeeee::::::e r:::::r r:::::rl::::l 555555555555:::::5 |
  12. | P::::P e:::::::::::::::::e r:::::r rrrrrrrl::::l 5:::::5 |
  13. | P::::P e::::::eeeeeeeeeee r:::::r l::::l 5:::::5 |
  14. | P::::P e:::::::e r:::::r l::::l 5555555 5:::::5 |
  15. | PP::::::PP e::::::::e r:::::r l::::::l5::::::55555::::::5 |
  16. | P::::::::P e::::::::eeeeeeee r:::::r l::::::l 55:::::::::::::55 |
  17. | P::::::::P ee:::::::::::::e r:::::r l::::::l 55:::::::::55 |
  18. | PPPPPPPPPP eeeeeeeeeeeeee rrrrrrr llllllll 555555555 |
  19. | |
  20. +----------------------------------------------------------------------------------------+
  21.  
  22. _ ___ _ ___ _ _ ___ ___ ___ _ _ _ ___ ___ ___ ___
  23. | | | __| /_\ | _ \ \| | | _ \ __| _ \ | | \| |/ _ \ / _ \| _ ) __|
  24. | |__| _| / _ \| / .` | | _/ _|| / |__ | .` | (_) | (_) | _ \__ \
  25. |____|___/_/ \_\_|_\_|\_| |_| |___|_|_\____| |_|\_|\___/ \___/|___/___/
  26.  
  27.  
  28. Perl5 is the standard installed in most Debian and Ubuntu based systems.
  29.  
  30. The feature perl is most known for, is its built-in regexp handling.
  31. For example:
  32.  
  33. $string =~ s/DROP\sTABLE/No SQL injection attacks here, thanks!/sgi;
  34.  
  35. To use perl on a GNU/Linux distro, its just to start using it.
  36. Its preinstalled and ready to go!
  37.  
  38. But if you want to go more advanced, I would recommend updating CPAN and
  39. making it ready to use.
  40. To start CPAN, you do:
  41.  
  42. sebastian@sebbe.eu:~$ sudo perl -MCPAN -e shell;
  43. [sudo] password for sebastian:
  44.  
  45. You will be asked to configure it. The default is a good option for most, but
  46. if there is something you dislike, you could always change that option.
  47. Then you will appear at the CPAN prompt:
  48.  
  49. cpan[1]>
  50.  
  51. Then at this prompt, type:
  52.  
  53. cpan[1]> install CPAN
  54.  
  55. it will update to latest version.
  56. Then when you are back at prompt, type:
  57.  
  58. cpan[2]> reload CPAN
  59. (CPAN__unchanged__v2.18)(CPAN::Author__unchanged__v5.5002)(CPAN::CacheMgr__unchanged__v5.5002)
  60. (CPAN::Complete__unchanged__v5.5001)(CPAN::Debug__unchanged__v5.5001)
  61. (CPAN::DeferredCode__unchanged__v5.50)(CPAN::Distribution__unchanged__v2.18)
  62. (CPAN::Distroprefs__unchanged__v6.0001)(CPAN::Distrostatus__unchanged__v5.5)
  63. (CPAN::Exception::RecursiveDependency.....v5.5001)(CPAN::Exception::yaml_not_installed..v5.5)
  64. (CPAN::FTP__unchanged__v5.5008)(CPAN::FTP::netrc__unchanged__v1.01)
  65. (CPAN::HandleConfig__unchanged__v5.5008)(CPAN::Index__unchanged__v2.12)
  66. (CPAN::InfoObj__unchanged__v5.5)(CPAN::LWP::UserAgent....v1.9601)
  67. (CPAN::Module__unchanged__v5.5003)(CPAN::Prompt__unchanged__v5.5)
  68. (CPAN::Queue__unchanged__v5.5002)(CPAN::Shell__unchanged__v5.5006)
  69. (CPAN::Tarzip__unchanged__v5.5012)(CPAN::Version__unchanged__v5.5003)
  70. 11 subroutines redefined
  71.  
  72. cpan[3]>
  73.  
  74. At this time, you can either install one or more modules:
  75.  
  76. cpan[3]> install XXX:XXX
  77.  
  78. where XXX:XXX is the module name (CaSe SeNsItIvE!!!)
  79.  
  80. or just exit out if you dont need to use CPAN at this time:
  81.  
  82. cpan[3]> exit
  83. Terminal does not support GetHistory.
  84. Lockfile removed.
  85. sebastian@sebbe.eu:~$
  86.  
  87. ____ _ __ _____ __ __ ______ __ _ __
  88. / __ \__ __(_)____/ /__ / ___// /_____ ______/ /_ /_ __/_ __/ /_____ _____(_)___ _/ /
  89. / / / / / / / / ___/ //_/ \__ \/ __/ __ `/ ___/ __/ / / / / / / __/ __ \/ ___/ / __ `/ /
  90. / /_/ / /_/ / / /__/ ,< ___/ / /_/ /_/ / / / /_ / / / /_/ / /_/ /_/ / / / / /_/ / /
  91. \___\_\__,_/_/\___/_/|_| /____/\__/\__,_/_/ \__/ /_/ \__,_/\__/\____/_/ /_/\__,_/_/
  92.  
  93.  
  94.  
  95. #!/usr/bin/perl
  96. #############################
  97. ######## Quick Start ########
  98. #############################
  99.  
  100. #Perl @ irc.anonops.com port 6697
  101. #Current authors, SebastianNielsen
  102.  
  103. #This file is made to help people learn the perl programming language, as a part of
  104. #opspeakcode, a legal and productive op.
  105. #Guys, there is nothing illegal about programming perl, SO POST CODE WHEN GIVING
  106. #QUESTIONS!!! READ DOCS!!!!! DISCUSS OPENLY!!!!
  107.  
  108. #THE BIBLE OF PERL: https://perldoc.perl.org
  109.  
  110. @alphabet = ( 'a' .. 'z' );
  111. $letter = $alphabet[int(rand($#alphabet + 1))];
  112. print $letter; # prints random letter between a - z
  113.  
  114. # when learning any programming language, you must know 4 main things.
  115. # 1) data types 2) syntax (the grammar of the language) 3) logic (how is it interpretted)
  116. # 4) Data structures (modules, classes, etc)
  117. # then, you must understand how all 4 of these things are inter-connected. Once you learn these,
  118. # you can go to another language and learn it much faster
  119. # than you did your first language, because the concepts will already be familiar.
  120.  
  121. #Variables are just used.
  122. #For example:
  123. $a = 12;
  124.  
  125. #To import a library, use the "use" keyword:
  126. use Convert::Base32 qw(decode_base32); #qw means quote the content, like 'decode_base32'.
  127. #this loads the Convert::Base32 module and imports the decode_base32 function in main namespace.
  128.  
  129. #To install Convert::Base32, refer to first part of this document, write "install Convert::Base32"
  130. #in CPAN prompt.
  131.  
  132. #Important built-in functions:
  133. length($a);
  134. int($a);
  135.  
  136. #Variables and escapes are expanded in double-quoted strings but not single-quoted strings;
  137.  
  138. print 'Nice variable: $a\n';
  139. print "Nice variable: $a\n";
  140.  
  141. #Lets print some base32 encoded content to a file, so we both learn how to write,
  142. #append and read to files to the system, and also gets to use the decode_base32 module we just
  143. #imported above, but also learn how to concatenate strings, which are done with the . character.
  144.  
  145. #Common mistake: There should be NO COMMA between the filehandle and content when print'ing to
  146. #a filehandle. A filehandle can also be a handle that refers to a internet socket when
  147.  
  148. open(FILEHANDLE, ">/tmp/tempfile");
  149. print FILEHANDLE "NBSXSIDUNBSXEZJMEBESA53SNF2HIZLOEBQSA3TJMNSSA5DFPB2CAZTJNRSQ\n";
  150. close(FILEHANDLE);
  151. open(ANOTHERTHING, ">>/tmp/tempfile");
  152. print ANOTHERTHING "JZUWGZJAMFYHAZLOMQQSAQLMONXSA53SNF2GKIDXNFWGYIDCMUQHEZLQNRQWGZLEEBUW4IDUNBUXGIDUMV4HILROFY\n";
  153. close(ANOTHERTHING);
  154.  
  155. open(GONNAREAD, "/tmp/tempfile");
  156. @filecontent = <GONNAREAD>;
  157. close(GONNAREAD);
  158.  
  159. foreach $line (@filecontent) {
  160. $line =~ s/\n//sgi; #Delete any newlines from $line
  161. $decoded_line = decode_base32($line);
  162. $decoded_line =~ s/write/read/gi;
  163. print "One line of the file, decoded: ".$decoded_line."\n";
  164. }
  165.  
  166. #Backticks are used to execute system commands and wait for reply, here we do it uppercase aswell:
  167. $commandresult = `whoami`;
  168. print "I am: ".uc($commandresult);
  169.  
  170.  
  171. No_reply("Hey","There");
  172.  
  173. $data = I_gonna_reply("With what?");
  174. print "I got a reply: ".$data."\n";
  175.  
  176. #Functions:
  177. sub No_reply() {
  178. $first_argument = $_[0];
  179. $second_argument = $_[1];
  180. print $first_argument."--".$second_argument."\n";
  181. }
  182.  
  183. sub I_gonna_reply() {
  184. $first_argument = $_[0];
  185. print "Gonna send back this to caller: ".$first_argument."\n";
  186. return $first_argument;
  187. }
  188.  
  189.  
  190. #
  191. # _ __ __ __ _
  192. # / | / /__ / /__ ______ _____/ /__(_)___ ____ _
  193. # / |/ / _ \/ __/ | /| / / __ \/ ___/ //_/ / __ \/ __ `/
  194. # / /| / __/ /_ | |/ |/ / /_/ / / / ,< / / / / / /_/ /
  195. #/_/ |_/\___/\__/ |__/|__/\____/_/ /_/|_/_/_/ /_/\__, /
  196. # /____/
  197. #
  198.  
  199. use IO::Socket::INET;
  200.  
  201. $server = IO::Socket::INET->new(LocalAddr => 'localhost', LocalPort => 1234, Proto => 'tcp', Listen => 5);
  202.  
  203. #Lets create a little daughter script in /tmp that will connect to the socket for us:
  204. #Then we also learn to print multiline...
  205.  
  206. open(SCRIPTFILE, ">/tmp/script.pl");
  207. print SCRIPTFILE <<'MULTILINE';
  208. #!/usr/bin/perl
  209.  
  210. use IO::Socket::INET;
  211. $socket = IO::Socket::INET->new(PeerAddr => 'localhost', PeerPort => 1234, Proto => 'tcp');
  212. print $socket "Hey there over TCP!";
  213. close($socket);
  214. MULTILINE
  215. close(SCRIPTFILE);
  216.  
  217. chmod(777, "/tmp/script.pl"); #Make it executable
  218. system("/tmp/script.pl &"); #Run the script.pl we just created in background
  219.  
  220. $socketobj = $server->accept(); #Accept the connection from /tmp/script.pl
  221.  
  222. $line_of_data = <$socketobj>; #Read from socket
  223.  
  224. close($server);
  225.  
  226. print "Got this over TCP: ".$line_of_data;
  227.  
  228. #Lets clean up after us:
  229. unlink("/tmp/tempfile");
  230. unlink("/tmp/script.pl");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement