How can I access raw private pastebine paste?

I know how to generate a user key using the pastebin API, but how can I use this user key to access the original private pair?

I am using Lua for this.

+7
source share
3 answers

Getting the output of the source paste buffer is not part of the Pastebin API :

This parameter is not actually part of our API, but you can still use it. To get RAW output from paste, you can use the RAW output URL:

http://pastebin.com/raw.php?i= 

Just add paste_key at the end of this url and you will get RAW output.

Since private pastes can only be seen by the user who created them, I assume that they use the I / O protocol for authentication. In this case, you will need to send it using an HTTP request.


Regarding the implementation of this in Lua (since you did not say which library you are using), I am going to go and recommend the HTTP module in LuaSocket or the wonderful Luvit ( http://luvit.io ).

+1
source

Here is a sample code for you:

 local https = require('ssl.https') https.TIMEOUT= 15 local private_raw_url="https://pastebin.com/raw/YOURPAGE" -- Change raw link local user_name, user_password = "USER", "PASS" -- and user with password local request_body = "submit_hidden=submit_hidden&user_name=".. user_name .. "&user_password=" .. user_password .. "&submit=Login" local resp = {} local res, code, headers, status = https.request ( { method = 'POST', url = "https://pastebin.com/login", headers = { Host = "pastebin.com", ["Content-Type"] = "application/x-www-form-urlencoded", ["Content-Length"] = string.len(request_body), Connection = "keep-alive", }, source = ltn12.source.string(request_body), sink = ltn12.sink.table(resp), protocol = "tlsv1", verify = "none", verifyext = {"lsec_continue", "lsec_ignore_purpose"}, options = { "all", "no_sslv2", "no_sslv3" } } ) if not headers['set-cookie']:find('pastebin_user') then print('bad login') return end resp={} local cookie = headers['set-cookie'] or '' local cookie1, cookie2, cookie3 = cookie:match("(__cfduid=%w+; ).*(PHPSESSID=%w+; ).*(pastebin_user=%w+; )" ) if cookie1 and cookie2 and cookie3 then cookie = cookie1 .. cookie2 .. cookie3 body, code, headers= https.request{ url = private_raw_url , headers = { --Host = "pastebin.com", ['Cookie'] = cookie, ['Connection'] = 'keep-alive' }, sink = ltn12.sink.table(resp) } if code~=200 then return end print( table.concat(resp) ) else print("error match cookies!" ) end 
+1
source

I know that it is a little late to answer the question, but I hope this helps someone later.

If you want to access unprocessed private pastes, you will first need to specify user created pastes. This is part of the API. This requires the user to log in.

Using this API, you can list all pastes created by a specific user. You need to send a valid POST request to the URL below to access the data:

 http://pastebin.com/api/api_post.php 

The answer you get will be an XML response as follows:

 <paste> <paste_key>0b42rwhf</paste_key> <paste_date>1297953260</paste_date> <paste_title>javascript test</paste_title> <paste_size>15</paste_size> <paste_expire_date>1297956860</paste_expire_date> <paste_private>0</paste_private> <paste_format_long>JavaScript</paste_format_long> <paste_format_short>javascript</paste_format_short> <paste_url>http://pastebin.com/0b42rwhf</paste_url> <paste_hits>15</paste_hits> </paste> 

After that, paste_key XML to get paste_key and paste_private . You need to check the paste_private value because you only need private pastes. The documentation states:

We have 3 valid values ​​that you can use with the api_paste_private parameter:

 0 = Public 1 = Unlisted 2 = Private (only allowed in combination with api_user_key, as you have to be logged into your account to access the paste) 

So, if your paste has paste_private set to 2 , get paste_key for it.

Once you have paste_key , use the API call to get the RAW insert. There is no username or password if you have an insert key for private paste.

Good luck

0
source

All Articles