ToKeiChun

Playcms Exploiter [Curl.php]

Apr 19th, 2020
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. <?php
  2. /*
  3. * @Wibuheker | https://github.com/wibuheker | Curl Class
  4. */
  5. class Curl {
  6. public $URL = null;
  7. public $ch;
  8. public function __construct()
  9. {
  10. $this->ch = curl_init();
  11. curl_setopt ($this->ch, CURLOPT_RETURNTRANSFER, 1);
  12. curl_setopt ($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
  13. curl_setopt ($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
  14. curl_setopt ($this->ch, CURLOPT_HEADER, 1);
  15. }
  16. public function SetHeaders($header)
  17. {
  18. curl_setopt ($this->ch, CURLOPT_HTTPHEADER, $header);
  19. }
  20. public function setTimeout($timeout)
  21. {
  22. curl_setopt ($this->ch, CURLOPT_TIMEOUT, $timeout);
  23. curl_setopt ($this->ch, CURLOPT_CONNECTTIMEOUT,$timeout);
  24. }
  25. public function Cookies($file_path)
  26. {
  27. $fp = fopen($file_path, 'wb');
  28. fclose($fp);
  29. curl_setopt ($this->ch, CURLOPT_COOKIEJAR, $file_path);
  30. curl_setopt ($this->ch, CURLOPT_COOKIEFILE, $file_path);
  31. }
  32. public function Follow()
  33. {
  34. curl_setopt ($this->ch, CURLOPT_FOLLOWLOCATION, 1);
  35. }
  36. public function Post($data)
  37. {
  38. curl_setopt ($this->ch, CURLOPT_URL, $this->URL);
  39. curl_setopt ($this->ch, CURLOPT_POST, 1);
  40. curl_setopt ($this->ch, CURLOPT_POSTFIELDS, $data);
  41. }
  42. public function Get()
  43. {
  44. curl_setopt ($this->ch, CURLOPT_URL, $this->URL);
  45. curl_setopt ($this->ch, CURLOPT_POST, 0);
  46. }
  47. public function Response()
  48. {
  49. $data = curl_exec ($this->ch);
  50. $header_size = curl_getinfo($this->ch, CURLINFO_HEADER_SIZE);
  51. $status_code = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
  52. $head = substr($data, 0, $header_size);
  53. $body = substr($data, $header_size);
  54. return json_decode(json_encode(
  55. array(
  56. 'status_code' => $status_code,
  57. 'headers' => self::HeadersToArray($head),
  58. 'body' => $body
  59. )
  60. ));
  61. }
  62. public function HeadersToArray($str) {
  63. $str = explode("\r\n", $str);
  64. $str = array_splice($str, 0, count($str) - 1);
  65. $output = [];
  66. foreach($str as $item) {
  67. if ($item === '' || empty($item)) continue;
  68. $index = stripos($item, ": ");
  69. $key = substr($item, 0, $index);
  70. $key = strtolower(str_replace('-', '_', $key));
  71. $value = substr($item, $index + 2);
  72. if (@$output[$key]) {
  73. if (strtolower($key) === 'set_cookie') {
  74. $output[$key] = $output[$key] . "; " . $value;
  75. } else {
  76. $output[$key] = $output[$key];
  77. }
  78. } else {
  79. $output[$key] = $value;
  80. }
  81. }
  82. return $output;
  83. }
  84.  
  85. }
Add Comment
Please, Sign In to add comment