Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # GO CHECK THE MINIMAL VERSION OF THIS PASTE:
- # (no comments, no hashtables.. in less than 40 lines)
- # https://pastebin.com/zQjAMW8J
- #
- #
- # YOUR PASTEBIN COOKIE SESSION!!!
- # MANDATORY!!
- # YOU CAN FIND IT IN YOUR BROWSER WITH THE COOKIE ID: 'PASTEBIN-FRONTEND'
- $PASTEBIN_SESSION = ""
- # PASTE
- $PASTEBIN_PASTE_ID = "Q3PWwwLk" # pastebin url ID, e.g.: https://pastebin.com/Y3Vp5RQH TAKING ONLY THE 'Y3Vp5RQH' PART
- $TEXTO_NUEVO = "EDITED WITH POWERSHELL GUIDE BY joelg4dea"
- # EDITION OPTIONS (FIELDS)
- $peticion_campos = @(
- @{
- 'PostForm' = 'text' # new edition text
- 'value' = $TEXTO_NUEVO # text value, e.g.: 'LETS GO GAMBLING!!' (modify variable {TEXTO_NUEVO} instead)
- }
- <# OTHER FIELDS THAT CAN BE MODIFIED WITH THE PETITION (UN-COMMENT TO ENABLE THEM):
- @{
- 'PostForm' = 'category_id' # paste's category
- 'valor' = '0' # category value. '4' = Cybersecurity
- }
- @{
- 'PostForm' = 'tag' # paste's tags
- 'valor' = '' # a list of tags (separated by , and without spaces) e.g.: 'html,css,js,php'
- }
- @{
- 'PostForm' = 'expiration' # paste's expiration time
- 'valor' = 'PREV' # 'PREV' = copy previous expiration time. 'N' = NEVER, '1Y' = 1 YEAR... (i'll leave the researching labor to you XD)
- }
- @{
- 'PostForm' = 'format' # paste's language
- 'valor' = '1' # also known as 'Syntax Highlighting'. '1' = NONE, '117' = PowerShell...
- }
- @{
- 'PostForm' = 'status' # paste's privacy
- 'valor' = '1' # statuses: '0' = public, '1' = not listed, '2' = private
- }
- @{
- 'PostForm' = 'folder_key' # paste's folder
- 'valor' = '' # idk your folders keys, figure it by yourself...
- }
- @{
- 'PostForm' = 'folder_name' # folder's name (it doesn't work at all)
- 'valor' = '' # doesn't work at all, if you want to move your paste to a folder you will need 'folder_key' only.
- }
- @{
- 'PostForm' = 'is_password_enabled' # protect your paste with a password?
- 'valor' = '0' # change it to '1' so you can set a password, un-comment 'PostForm' = 'password' (it is right below)
- }
- @{
- 'PostForm' = 'password' # your new paste's password
- 'valor' = '' # first set is_password_enabled to '1', then enter your password, e.g.: 'MYPASSWORD'
- }
- @{
- 'PostForm' = 'is_burn' # delete after read
- 'valor' = '0' # '0' = dont delete, '1' = delete after read
- }
- @{
- 'PostForm' = 'name' # your paste's name
- 'valor' = '' # it's plain text, e.g: 'Pastebin | edit your PASTE with POWERSHELL'
- }
- #>
- )
- # OTHER STUFF
- $pb = '---------------------------117' # petition's fields' separator. change at wish... altought not needed
- $nl = [char]10 # newline character v:
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- # DON'T MODIFY DONT MOIDFY DON'T MODIYF
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- # u've been warned. but you will need a traslator now...
- # creación de la sesión
- $p_sesion = $NULL # vaciado de la sessssion (por si las moscas)
- $p_sesion = New-Object Microsoft.PowerShell.Commands.WebRequestSession
- # cookie de sesión de pastebin (tomarla desde el navegador y pegarla en {PASTEBIN_SESSION})
- # importante no compartir con nadie este dato jkasjdkaljwdkajwdlkawd
- $p_sesion.Cookies.Add((New-Object System.Net.Cookie("pastebin-frontend", $PASTEBIN_SESSION, "/", "pastebin.com")))
- $user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0"
- # llamada para editar el post (y actualizar {p_sesion})
- $WR = $NULL # vaciado de la wr (por si ya estaba llena) [si la petición tira una excepción $A NO ES VACIADA]
- $WR = Invoke-WebRequest -UseBasicParsing -Uri "https://pastebin.com/edit/$($PASTEBIN_PASTE_ID)" -WebSession $p_sesion -UserAgent $user_agent
- # obtención del csrf que genera pastebin para la petición de edición del PASTE
- [String]$csrf = ""
- [String]$csrf = ($WR.RawContent -split '\r?\n' | Select-String '^.*input.*?name="_csrf' -Raw) -replace '^.*value *= *"(.*?)".*$', '$1'
- # creación de la petición (en modo hashtable para mejor redacción :v)
- $peticion = @(
- @{
- 'campo' = 'Content-Disposition: form-data; name="_csrf-frontend"' # campo de la petición (como los campos de arriba jaja)
- 'valor' = $csrf # csrf obtenido para que no nos rechace la petición
- }
- )
- # agregado de los campos DE ARRIBA en la petición (posiblemente hayan sido modificados)
- $peticion_campos | ForEach-Object {
- $peticion += @{
- 'campo' = 'Content-Disposition: form-data; name="PostForm['+ $_.PostForm + ']"'
- 'valor' = $_.value
- }
- }
- # conversión del hashtable a STRING (y algunos detalles que la petición necesita para funcionar...)
- [String]$peticion_string = "--$pb" + (($peticion | ForEach-Object { $nl + $_.campo + $nl + $nl + $_.valor + $nl }) -join "--$pb") + "--$pb--"
- [Byte[]]$peticion_bytes = ([System.Text.Encoding]::UTF8.GetBytes($peticion_string))
- # envío de la petición de edición
- $WR = $NULL
- $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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement