Advertisement
Joelg4dea

Pastebin | edit your PASTE with POWERSHELL

Oct 21st, 2024 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 6.08 KB | Source Code | 0 0
  1. #
  2. # GO CHECK THE MINIMAL VERSION OF THIS PASTE:
  3. # (no comments, no hashtables.. in less than 40 lines)
  4. # https://pastebin.com/zQjAMW8J
  5. #
  6. #
  7. # YOUR PASTEBIN COOKIE SESSION!!!
  8. # MANDATORY!!
  9. # YOU CAN FIND IT IN YOUR BROWSER WITH THE COOKIE ID: 'PASTEBIN-FRONTEND'
  10. $PASTEBIN_SESSION = ""
  11.  
  12. # PASTE
  13. $PASTEBIN_PASTE_ID = "Q3PWwwLk" # pastebin url ID, e.g.: https://pastebin.com/Y3Vp5RQH TAKING ONLY THE 'Y3Vp5RQH' PART
  14. $TEXTO_NUEVO = "EDITED WITH POWERSHELL GUIDE BY joelg4dea"
  15.  
  16.  
  17. # EDITION OPTIONS (FIELDS)
  18. $peticion_campos = @(
  19.     @{
  20.         'PostForm' = 'text' # new edition text
  21.         'value' = $TEXTO_NUEVO # text value, e.g.: 'LETS GO GAMBLING!!' (modify variable {TEXTO_NUEVO} instead)
  22.     }
  23.     <# OTHER FIELDS THAT CAN BE MODIFIED WITH THE PETITION (UN-COMMENT TO ENABLE THEM):
  24.     @{
  25.         'PostForm' = 'category_id' # paste's category
  26.         'valor' = '0' # category value. '4' = Cybersecurity
  27.     }
  28.     @{
  29.         'PostForm' = 'tag' # paste's tags
  30.         'valor' = '' # a list of tags (separated by , and without spaces) e.g.: 'html,css,js,php'
  31.     }
  32.     @{
  33.         'PostForm' = 'expiration' # paste's expiration time
  34.         'valor' = 'PREV' # 'PREV' = copy previous expiration time. 'N' = NEVER, '1Y' = 1 YEAR... (i'll leave the researching labor to you XD)
  35.     }
  36.     @{
  37.         'PostForm' = 'format' # paste's language
  38.         'valor' = '1' # also known as 'Syntax Highlighting'. '1' = NONE, '117' = PowerShell...
  39.     }
  40.     @{
  41.         'PostForm' = 'status' # paste's privacy
  42.         'valor' = '1' # statuses: '0' = public, '1' = not listed, '2' = private
  43.     }
  44.     @{
  45.         'PostForm' = 'folder_key' # paste's folder
  46.         'valor' = '' # idk your folders keys, figure it by yourself...
  47.     }
  48.     @{
  49.         'PostForm' = 'folder_name' # folder's name (it doesn't work at all)
  50.         'valor' = '' # doesn't work at all, if you want to move your paste to a folder you will need 'folder_key' only.
  51.     }
  52.     @{
  53.         'PostForm' = 'is_password_enabled' # protect your paste with a password?
  54.         'valor' = '0' # change it to '1' so you can set a password, un-comment 'PostForm' = 'password' (it is right below)
  55.     }
  56.     @{
  57.         'PostForm' = 'password' # your new paste's password
  58.         'valor' = '' # first set is_password_enabled to '1', then enter your password, e.g.: 'MYPASSWORD'
  59.     }
  60.     @{
  61.         'PostForm' = 'is_burn' # delete after read
  62.         'valor' = '0' # '0' = dont delete, '1' = delete after read
  63.     }
  64.     @{
  65.         'PostForm' = 'name' # your paste's name
  66.         'valor' = '' # it's plain text, e.g: 'Pastebin | edit your PASTE with POWERSHELL'
  67.     }
  68.     #>
  69. )
  70.  
  71.  
  72.  
  73. # OTHER STUFF
  74. $pb = '---------------------------117' # petition's fields' separator. change at wish... altought not needed
  75. $nl = [char]10 # newline character v:
  76. #
  77. #
  78. #
  79. #
  80. #
  81. #
  82. #
  83. #
  84. #
  85. #
  86. #
  87. #
  88. #
  89. #
  90. #
  91. #
  92. #
  93. #
  94. #
  95. #
  96. #
  97. #
  98. #
  99. #
  100. #
  101. #
  102. #
  103. #
  104. #
  105. #
  106. #
  107. #
  108. #
  109. #
  110. #
  111. #
  112. #
  113. #
  114. #
  115. #
  116. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  117. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  118. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  119. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  120. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  121. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  122. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  123. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  124. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  125. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  126. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  127. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  128. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  129. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  130. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  131. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  132. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  133. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  134. #   DON'T MODIFY DONT MOIDFY DON'T MODIYF
  135. #
  136. #
  137. #
  138. #
  139. #
  140. #
  141. #
  142. #
  143. #
  144. #
  145. #
  146. #
  147. # u've been warned. but you will need a traslator now...
  148. # creación de la sesión
  149. $p_sesion = $NULL # vaciado de la sessssion (por si las moscas)
  150. $p_sesion = New-Object Microsoft.PowerShell.Commands.WebRequestSession
  151. # cookie de sesión de pastebin (tomarla desde el navegador y pegarla en {PASTEBIN_SESSION})
  152. # importante no compartir con nadie este dato jkasjdkaljwdkajwdlkawd
  153. $p_sesion.Cookies.Add((New-Object System.Net.Cookie("pastebin-frontend", $PASTEBIN_SESSION, "/", "pastebin.com")))
  154. $user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0"
  155.  
  156.  
  157.  
  158.  
  159. # llamada para editar el post (y actualizar {p_sesion})
  160. $WR = $NULL # vaciado de la wr (por si ya estaba llena) [si la petición tira una excepción $A NO ES VACIADA]
  161. $WR = Invoke-WebRequest -UseBasicParsing -Uri "https://pastebin.com/edit/$($PASTEBIN_PASTE_ID)" -WebSession $p_sesion -UserAgent $user_agent
  162.  
  163.  
  164. # obtención del csrf que genera pastebin para la petición de edición del PASTE
  165. [String]$csrf = ""
  166. [String]$csrf = ($WR.RawContent -split '\r?\n' | Select-String '^.*input.*?name="_csrf' -Raw) -replace '^.*value *= *"(.*?)".*$', '$1'
  167.  
  168.  
  169.  
  170.  
  171. # creación de la petición (en modo hashtable para mejor redacción :v)
  172. $peticion = @(
  173.     @{
  174.         'campo' = 'Content-Disposition: form-data; name="_csrf-frontend"' # campo de la petición (como los campos de arriba jaja)
  175.         'valor' = $csrf # csrf obtenido para que no nos rechace la petición
  176.     }
  177. )
  178. # agregado de los campos DE ARRIBA en la petición (posiblemente hayan sido modificados)
  179. $peticion_campos | ForEach-Object {
  180.     $peticion += @{
  181.         'campo' = 'Content-Disposition: form-data; name="PostForm['+ $_.PostForm + ']"'
  182.         'valor' = $_.value
  183.     }
  184. }
  185.  
  186. # conversión del hashtable a STRING (y algunos detalles que la petición necesita para funcionar...)
  187. [String]$peticion_string = "--$pb" + (($peticion | ForEach-Object { $nl + $_.campo + $nl + $nl + $_.valor + $nl }) -join "--$pb") + "--$pb--"
  188. [Byte[]]$peticion_bytes = ([System.Text.Encoding]::UTF8.GetBytes($peticion_string))
  189.  
  190.  
  191.  
  192.  
  193.  
  194. # envío de la petición de edición
  195. $WR = $NULL
  196. $WR = Invoke-WebRequest -Method Post -UseBasicParsing -Uri "https://pastebin.com/edit/$($PASTEBIN_PASTE_ID)" -UserAgent $user_agent -WebSession $p_sesion -ContentType "multipart/form-data; boundary=$($pb)" -Body $peticion_bytes
  197.  
  198.  
  199.  
  200.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement