Pastebin Script (Uploader)

By H_M on Jul 19, 2008

This script can be VERY useful for scripters who are trying to help someone out, and distributing a script easily.

(Supported abilities in current version):

  • Name textbox
  • Up to 16kb total script upload size (Might be larger, I don't quite know.)
  • Private pastebin abilities
  • Syntax Highlighting abilities
  • Simple dialog
  • Status indicator
  • History logging and saving post
  • 0 BUGS!

This is my first socket script, constructive criticism is very welcome :D (Just don't say anything unless you know a fix for it, kthx.)
(Thanks to mountaindue for pointing out a better way to use /did)
(Thanks to jonesy44 for pointing out a better way to draw the combobox items)

-What to look forward to-

  • Version 1.4.1 will have 2 different dialog sizes, and will store settings between sessions.
  • Version 1.4.1 will also have the ability to hold more information about old post.

-Screenshots-

Image

Image

/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-Script by H_M (With some help from friends)
-Version 1.3.2 (No bugs found, stable)
-Contact info: diotecktec@gmail.com 
-IRC network: irc.wyldryde.org #hackerz 
*/;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias paste {
  if ($dialog(paste) == $null) {
    dialog -m paste paste
    write_combobox
    did -b paste 7,22 1 
    did -ck paste 14 1
  }
  else {
    dialog -v paste paste
  }
}
alias write_combobox { ; Thanks jonesy44 
  var %string = Text C C++ HTML Java Javascript Lua Perl PHP Python Ruby ABAP ActionScript Ada Apache-Log-File AppleScript ASM ASP AutoIt Bash Blitz-Basic BNF C C-for-Macs CAD-DCL CAD-Lisp Coldfusion CSS D Delphi Diff DOS Eiffel Fortran FreeBasic Genero GameMaker Groovy Haskell mIRC
  var %x = 1
  while (%x <= $numtok(%string,32)) {
    did -o paste 14 %x $gettok(%string,%x,32)
    inc %x
  }
}
menu channel {
  Pastebin:/paste
}
alias box_size {
  var %opt = $1
  if (%opt == 2) { var %target = pastehist | var %cid = 5 }
  else { var %target = paste | var %cid = 6 }
  var %x = 1
  var %n = $did(%target,%cid).lines
  var %size = 0
  while %x <= %n {
    var %line = $did(%target,%cid,%x).text
    if (%opt == 1) {
      if (%line == $null) { %size = $calc(%size + $len(% $+ 0A)) }
      else { %size = $calc(%size + $len($urlencode(%line) $+ % $+ 0A)) }
    }
    else { %size = $calc(%size + $len(%line)) }
    inc %x
  }
  return %size
}
alias urlencode {
  var %r = $regsubex($$1-,/([!#$%&'()*+,/:;=?@rn[] ])/g,% $+ $($base($asc(t),10,16)))
  $iif($isid,return,echo -a) %r
}
alias hist_load {
  var %x = $lines(pastebinhist.txt)
  if ($dialog(pastehist) !== $null) {
    dialog -t pastehist Pastebin History (Total Post: %x $+ )
  }
  var %l = 1
  while %x >= 1 {
    if ($dialog(pastehist) !== $null) {
      did -o pastehist 1 %l $read(pastebinhist.txt,nt,%x)
    }
    dec %x
    inc %l
  }
}
dialog pastehist {
  title Pastebin History (Total Post: 0)
  option dbu
  size -1 -1 350 200
  list 1, 5 5 140 180, vsbar
  text "0 chars, 0 lines, 0 kb, posted: N/A", 2, 150 190 195 8, center
  button "Close", 3, 75 185 70 12 
  button "Clear History", 4, 5 185 70 12 
  edit "", 5, 150 5 195 183, multi vsbar hsbar read
}
dialog paste {
  title "Pastebin Uploader v1.3.2 (Script by H_M)"
  option dbu
  size -1 -1 360 325
  edit "", 4, 28 11 60 10
  edit "", 19, 223 11 50 10 ; 300 11 50 10 - 235 295 50 10
  edit "", 6, 10 24 340 263, multi return hsbar vsbar autohs autovs
  box "Input", 5, 5 4 350 288
  box "", 9, 5 289 350 31
  button "Paste", 7, 325 294 25 12
  button "Clear", 8, 325 306 25 12
  button "Settings", 22, 289 294 35 12
  button "History", 23, 289 306 35 12
  combo 14, 300 11 50 10, drop 
  link "", 11, 71 311 130 8
  text "Chars Used: 0 (1 line)", 10, 9 293 100 8
  text "URL (Right click to copy):", 12, 9 311 60 8
  text "Name:", 21, 11 13 17 8
  text "Status: Waiting", 13, 9 302 50 8
  text "Highlight:", 17, 276 13 24 8
  text "Priv. Paste (Empty for normal):", 18, 147 13 76 8
}
on *:dialog:pastehist:*:*: {
  if ($devent == sclick) {
    if ($did == 3) { dialog -x pastehist }
    if ($did == 4) { 
      write -c pastebinhist.txt 
      did -r pastehist 1,5 1 
      did -o pastehist 2 1 0 chars, 0 lines, 0 kb, posted: N/A
      dialog -t pastehist Pastebin History (Total Post: 0)
    }
    if ($did == 1) {
      did -r pastehist 5
      var %fname = $remove($did(pastehist,1).seltext,.,:,/) $+ .txt
      loadbuf 0 -o pastehist 5 %fname
      did -o pastehist 2 1 $box_size(2) chars, $calc($did(5).lines - 1) lines, $round($calc($file(%fname).size / 1000),2) kb, posted: $asctime($file(%fname).ctime,m/dd/yy - h:nntt) 
    }
  }
  if ($devent == dclick) {
    if ($did == 1) { 
      run $did(pastehist,1).seltext 
      dialog -x pastehist
    }
  }
}
on *:dialog:paste:*:*: {
  if ($devent == close) {
    if ($dialog(pastehist) !== $null) { dialog -x pastehist }
  }
  if ($devent == edit) {
    if ($did == 6) { 
      if ($box_size == 0) { did -b paste 7 1 }
      else { did -e paste 7 1 } 
      did -o paste 10 1 Chars Used: $box_size ( $+ $did(paste,6).lines $iif($did(paste,6).lines == 1,line,lines)) $+ ) 
    }
    if ($did == 19) {
      if ($did(paste,19).text !== $null) { set %privatepst $remove($lower($did(paste,19).text),!,#,$,%,&,',*,+,/,:,;,,=,?,@) $+ . } 
      else { unset %privatepst }
    }
  }
  if ($devent == sclick) {
    if ($did == 23) {
      if ($dialog(pastehist) == $null) { 
        if ($dialog(pasteset) !== $null) { dialog -x pasteset }
        dialog -mo pastehist pastehist
        hist_load
      }
      else { dialog -ve pastehist pastehist }
    }
    if ($did == 14) {
      if ($did(paste,14).seltext !== none) || ($did($paste,14).seltext == $null) { set %pst.frmt $replace($did(paste,14).seltext,-,$chr(32)) }
      else { unset %pst.frmt }
    }
    if ($did == 7) {
      if ($did(6) !== $null) {
        %paste.user = $iif($did(4) == $null,Anonymous,$did(4))
        sockclose paste
        did -o paste 13 1 Status: Uploading...
        did -b paste 4,6,7,14,19 1
        sockopen Paste %privatepst $+ pastebin.com 80
      }
    }
    if ($did == 8) {
      did -b paste 7 1
      did -o paste 10 1 Chars Used: 0 (1 line)
      did -o paste 13 1 Status: Waiting
      did -re paste 4,6,11,19 1
      did -ec paste 14 1
      unset %privatepst
      unset %pst.frmt
    }
  }
  if ($devent == dclick) { if ($did == 11) { run $did(paste,11).text } }
  if ($devent == rclick) { if ($did == 11) { clipboard $did(paste,11).text } }
}
on *:sockopen:Paste: {
  var %a = $+(parent_id=&format= $+ $iif(%pst.frmt,$lower(%pst.frmt),text) $+ &paste=Send&poster=,%Paste.User,&code2=,)
  unset %pst.frmt
  %paste_lc = 0
  %paste_found302 = 0
  sockwrite -n $sockname POST /pastebin.php HTTP/1.0
  sockwrite -n $sockname Host: %privatepst $+ pastebin.com
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname Content-length: $calc($len(%a) + $box_size(1))
  sockwrite $sockname $crlf
  sockwrite $sockname %a
  unset %privatepst
  var %cnt = 1
  var %ttl = $did(paste,6).lines
  while %cnt <= %ttl {
    var %line = $did(paste,6,%cnt).text
    if (%line == $null) {
      %line = % $+ 0A
      sockwrite $sockname %line
    }
    else {
      var %encd = $urlencode(%line)
      sockwrite $sockname %encd $+ % $+ 0A
    }
    inc %cnt
  }
}
on *:sockread:Paste: {
  var %a
  sockread %a
  if (%paste_lc == 0 && 200 isin %a) {
    did -o paste 13 1 Status: Pasting failed 
    sockclose $sockname
    unset %paste_lc
    unset %paste_found302
    halt
  }
  if (%paste_lc == 0 && 302 isin %a) {
    did -o paste 13 1 Status: Completed
    %paste_found302 = 1
    inc %paste_lc
  }
  else if (%paste_found302 == 1 && Location: isin %a) {
    var %t = $regex(%a,/Location: (.*)$/g)
    did -o paste 11 1 $regml(1)
    write pastebinhist.txt $regml(1)
    savebuf -eo paste 6 $remove($regml(1),.,:,/) $+ .txt
    hist_load
    unset %paste_lc
    unset %paste_found302
    halt
  }
}

Comments

Sign in to comment.
slub77   -  Feb 25, 2010

hey dude great script, trying to figure how you make it send information to the pastebin box, can you send me a pm with a quick explanation, trying to learn how to send information, and also how to make it send the info when you put it in the box aka
:you put your text in to the pastebin box, then you send:

HOW???

also pastebin has a new layout, so this script may no longer work right :/

 Respond  
Ghost-writer   -  Aug 19, 2009

patx i thought you only went on a scale of 1-5

 Respond  
PATX   -  Aug 19, 2009

6/10 i like it god job

 Respond  
Castor Troy   -  Nov 04, 2008

Hmm, it doesn't get the full script sometimes.

I tested it with this slapper script: http://obi.pastebin.com/m3e956cd3

But this is all it gets when I upload it with the script: http://pastebin.com/d293af14c

It happened with a few other scripts, but then I tried copying a bunch of chat from the buffer and it pasted fine with the script. I glanced at the code, I think it's in the way the "alias urlencode" sets the %r, but I figured let you know since it's a great script, I really like it and I know a lot of ppl seem to like it too. :P

Also just a thought, have the pastebinhist.txt and httppastebincom***.txt be wrote to $scriptdir since a lot of ppl have scripts in a Scripts or System folder inside the mirc directory. And maybe even have it write to it own folder in there, something like this maybe...

on *:LOAD:{
  if (!$exists($scriptdirPastbin)) {
    mkdir $scriptdirPastbin
  }
}

;Then for the pastebinhist.txt and httppastebincom***.txt

write $scriptdirPastbin\pastebinhist.txt

It's not gonna be like that in your script obviously but just a quick way to show u what I was thinking. Once again, great script. :)

 Respond  
Eugenio   -  Jul 26, 2008

Hi H_M
btw amazing code
atleast 7/10
/me rates 8

dont mind furbeh, hes tampons always in a twist.
-.-'

 Respond  
EL   -  Jul 26, 2008

ROFL TMD\'s

 Respond  
H_M   -  Jul 26, 2008

And lastly, Furby, you shouldn\'t insult people by calling them TropicalMeltdown\'s, that\'s just rude.

 Respond  
H_M   -  Jul 26, 2008

Furby, what did I do to you lmao? I only said that comment as a joke. Also, TropicalMeltdown copies code, which is lame. I write most my stuff originally -- Or I find code and change it a LOT (I don\'t call it my own if it\'s still even remotely the same).

This time since it was my first socket script, I looked at another script real quick to see how it worked, that\'s all. (It was yours, http://www.hawkee.com/snippet/3909/, but it didn\'t work, so I tried to work on it and fixed it up -- If it\'ll make you feel better, i\'ll add a credit in that says you wrote the original script, sorry if I upset you mate -- But in my defence, the only thing that is alike in my code is pretty much the dialog name and socket name, and that\'s it.)

--

And jonesy44: mIRC highlighting has an internal error, and it\'s not my scripts fault. Try using it directly on the website, it will do the same thing mate :D

 Respond  
F*U*R*B*Y*   -  Jul 25, 2008

H_M, I have to ask, are you TropicalMeltdown by any chance?

a - your both assholes
b - you take everything everyone says the wrong way
c - you both post a message after another message after another message.........

it all bases around this one: http://www.hawkee.com/snippet/4758/

 Respond  
Jonesy44   -  Jul 25, 2008

Ahh there we go;

http://pastebin.com/d34d3ead7

paste it with \"miRC\" highlighting..

 Respond  
Jonesy44   -  Jul 25, 2008

Didn\'t work this time :(

I just got a lot of preg_replace or something errors, and then the code was in grey as if the hardcode was changed.. my bad.

 Respond  
F*U*R*B*Y*   -  Jul 25, 2008

No Life! :P

 Respond  
EL   -  Jul 25, 2008

;o i have 916 comments ;p

 Respond  
Jonesy44   -  Jul 25, 2008

Typo, i will try it again, the paste may be in the scripts history.

 Respond  
F*U*R*B*Y*   -  Jul 25, 2008

if you have over 1,000 post then it just proves you have no life.

 Respond  
F*U*R*B*Y*   -  Jul 25, 2008

can you please stop this as no one really cares about post count?

 Respond  
Jonesy44   -  Jul 25, 2008

A hack, H_M is opening something for you to do something, without authorised access. I\'m not saying it kills the site, i\'m saying it returns a lot of PHP errors, which means, the hardcode is temporarily (sorta virtually) changed.

 Respond  
EL   -  Jul 25, 2008

Rofl@Comment count...sends no further comments...

 Respond  
H_M   -  Jul 25, 2008

Typo: Oh I know, I just don\'t care, doing it ranks up my comment count anyway >.>

-- Umm, Furby, this was a joke......... lmao

 Respond  
Typo   -  Jul 25, 2008

H_M, you can edit any of your own comments to add to it or just change it, this makes it so u dont have to make 3 posts in two minutes.

Very nice script btw. Really handy for people who pastebin even just every so often.

Jonesy44, wth are you talking about? Please explain your statement because I find it highly unlikely that a simple socket managed to accidntly open up some vulnerability in a website.

 Respond  
H_M   -  Jul 25, 2008

Jonesy, umm.. What?! No, all it does is fill in the textboxes \"poster\" and \"code2\" then reads the return of the location.

There\'s no way it would \"hack the site\", it\'s just a glitch.

  • EDIT:

I posted the script itself.... http://pastebin.com/d3a067020 .... Did nothing.

 Respond  
Jonesy44   -  Jul 24, 2008

Lmfao!

No idea how, but pasting the script, using the script into pastebin hacks the site.

 Respond  
Boredcollegekid   -  Jul 24, 2008

Works very nice. Maybe auto paste ability? ie more than 10 lines it autopastes to pastebin and posts the link.

 Respond  
H_M   -  Jul 24, 2008

:)

 Respond  
napa182   -  Jul 24, 2008

nice work on ur frist socket script and a helpfull script at that. keep up the good work 9/10

 Respond  
Jonesy44   -  Jul 23, 2008

Sorted (Y) good stuff H_M

 Respond  
H_M   -  Jul 22, 2008

Thanks guys, and i\'ll try to work with that jonesy44 :D

 Respond  
Darkkeeper   -  Jul 22, 2008

Very awsum and very usefull, Majorly usefull on the server im on lolz, i give it a 10/10

 Respond  
Jonesy44   -  Jul 22, 2008

RE: \"; If anyone has any idea on how to get the list better, let me know\";

var %string = PHP SQL .. all the names in one variable
;sets all the paramaters into one string, rather than redoing it over and over again. and sets a constant value of paramaters used later
var %x = 1
;provides a variable number for select the token from %string
while (%x <= $numtok(%string,32)) {
  did -o paste 14 %x $gettok(%string,%x,32)
  ;adds the token from the string to the list in slot %x
  inc %x
}
 Respond  
Jonesy44   -  Jul 22, 2008

Awesome script, realy helpful to share scripts so easily. NIce one. 9/10

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.