Advertisement
Joelg4dea

edit your pastebin pastes with POWERSHELL

Oct 22nd, 2024
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #
  2. #
  3. #
  4. # THIS IS THE VERY LEAST YOU NEED TO POST AN EDIT REQUEST TO PASTEBIN
  5. # ORIGINAL (MORE COMPLEX): https://pastebin.com/N4YsJQiC
  6. # THIS SAME PASTE BUT WITH COMMENTS: https://pastebin.com/jFgnC7H7
  7. #
  8. #
  9. #
  10. $ptboundary = 'SOMERANDOMTEXTeiRmyvWHDqaCPQLxFCUpXvKyeabAd7cOEI0cjxr'
  11. $PASTE_ID = "YOUR PASTE'S ID GOES HERE"
  12. $MY_NEW_TEXT = "YOUR FINAL TEXT GOES HERE"
  13. $COOKIE_VALUE = "YOUR COOKIE GOES HERE"
  14.  
  15.  
  16.  
  17. $session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
  18. $session.Cookies.Add((New-Object System.Net.Cookie(
  19.     "pastebin-frontend",
  20.     $COOKIE_VALUE,
  21.     "/",
  22.     "pastebin.com"
  23. )))
  24.  
  25.  
  26.  
  27. $WR = Invoke-WebRequest `
  28. -Uri "https://pastebin.com/edit/$PASTE_ID" `
  29. -WebSession $session `
  30.  
  31.  
  32.  
  33. $csrf = ($WR.RawContent -split '\r?\n' | Select-String '^.*input.*?name="_csrf' -Raw) -replace '^.*value *= *"(.*?)".*$', '$1'
  34.  
  35.  
  36.  
  37. $STRING = @(
  38.     "--$ptboundary"
  39.     'Content-Disposition: form-data; name="_csrf-frontend"'
  40.     ''
  41.     $csrf
  42.     "--$ptboundary"
  43.     'Content-Disposition: form-data; name="PostForm[text]"'
  44.     ''
  45.     $MY_NEW_TEXT
  46.     "--$ptboundary--"
  47. ) -join "`n"
  48.  
  49. $BYTES = ([System.Text.Encoding]::UTF8.GetBytes($STRING))
  50.  
  51.  
  52.  
  53. Invoke-WebRequest -Method Post -Uri "https://pastebin.com/edit/$PASTE_ID" `
  54. -WebSession $session `
  55. -ContentType "multipart/form-data; boundary=$ptboundary" `
  56. -Body $BYTES
  57.  
  58.  
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement