Hack Forums
[C#] [Request] An app to call my website's API (a pastebin alt.) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] [Request] An app to call my website's API (a pastebin alt.) (/showthread.php?tid=4372304)

Pages: Pages 1 2


[Request] An app to call my website's API (a pastebin alt.) - Damdomy - Aug 1, 2014

Hey guys,

Not sure if this is allowed (a request). But i basically need a simple desktop app that creates a context menu link that would contact my api at http://paste.sx
Then it would upload the selected files contents.

So right click > upload to paste.sx
The app could have a settings page to specify the API key to contact the API.

The API docs are here: http://paste.sx/029
They're only in PHP for now but hopefully others can expand it when needed.

I would be grateful if someone could do this, i think this is very useful for many people. I cannot pay, unfortunately but the source will have your name and you will be credited where credit is due.


* - Dispersia - Aug 1, 2014

I will do this once I get off my next flight (assuming I'm not to tired, I don't move back into my new home until about 12). But on a side note, there isn't a real big need for an API for this. Your csrfToken can be brought out by [<input type="hidden" name="csrfToken" value="Y8mUYbh3yrm4UfDYytRfpKfGa4rDOzR/goSKJq/u/mY"], then just upload title + content + password if wanted into a single request. Would be the same speed. On a side note, you may want to make that a little more secure, I could spam thousands of them a second and fill your server otherwise. However, I will give you that, it looks beautiful. I love what your website looks like. (I just posted one 'test' 'test' just to demonstrate, I can't see any blockers for spam so.)

But ya, I'll write for your api soon. (well hopefully within next 8-10 hours)

On a side note, I like how your pastes are doxes, saying fuck paste.sx or dos scripts. Lol


* - Damdomy - Aug 1, 2014

(Aug 1, 2014 05:02 PM)Dispersia Wrote:  I will do this once I get off my next flight (assuming I'm not to tired, I don't move back into my new home until about 12). But on a side note, there isn't a real big need for an API for this. Your csrfToken can be brought out by [<input type="hidden" name="csrfToken" value="Y8mUYbh3yrm4UfDYytRfpKfGa4rDOzR/goSKJq/u/mY"], then just upload title + content + password if wanted into a single request. Would be the same speed. On a side note, you may want to make that a little more secure, I could spam thousands of them a second and fill your server otherwise. However, I will give you that, it looks beautiful. I love what your website looks like. (I just posted one 'test' 'test' just to demonstrate, I can't see any blockers for spam so.)

But ya, I'll write for your api soon. (well hopefully within next 8-10 hours)

On a side note, I like how your pastes are doxes, saying fuck paste.sx or dos scripts. Lol

Hi, thanks for your comment.
There already is an API, so it would just be a C# api caller (POSTer). Refer here: https://paste.sx/029

What do you mean the csrfToken can be brought out?

I would like you to demonstrate that the home page is spam-able.

About the doxes and such, there will be a report button later on.

Looking forward for the app and goodluck with your flight :)


* - +Haze - Aug 1, 2014

Just use GET variables on your php to send the data using a webclient on c#


* - Damdomy - Aug 2, 2014

(Aug 1, 2014 05:42 PM)+Haze Wrote:  Just use GET variables on your php to send the data using a webclient on c#

If i understand you correctly, GET wouldn't be the best since it has a data limit.


* - iVision - Aug 2, 2014

I would write this for you, working on it right now. However with your json request thingy it is quite hard to defer upload instead of buffer it. The problem is that you require to put the file content as a string in the json format. So that means we have to load the whole file into memory, and that isn't a very good idea if it is a large file. I try to figure it out..
But the real reason for this reply is, can you provide me an api key and what exactly is the format of the response? I'm not good at json but is this right:
Code
{"status":"Error","message":"API Key not set."}

public string Status { get; set; }
public string Message { get; set; }

What other statuses can you return? Only indication of failure and success? Btw the context menu is just registry change.

Note: If you want more then just this api like a fancy gui you have to ask someone else or provide your own :P


* - Secret Agent - Aug 2, 2014

You cannot use POST webrequest method because you have CSRF protection.


* - Damdomy - Aug 2, 2014

(Aug 2, 2014 02:00 PM)iVision Wrote:  I would write this for you, working on it right now. However with your json request thingy it is quite hard to defer upload instead of buffer it. The problem is that you require to put the file content as a string in the json format. So that means we have to load the whole file into memory, and that isn't a very good idea if it is a large file. I try to figure it out..
But the real reason for this reply is, can you provide me an api key and what exactly is the format of the response? I'm not good at json but is this right:
Code
{"status":"Error","message":"API Key not set."}

public string Status { get; set; }
public string Message { get; set; }

What other statuses can you return? Only indication of failure and success? Btw the context menu is just registry change.

Note: If you want more then just this api like a fancy gui you have to ask someone else or provide your own :P

Hi, you can get an API by registering then go to your account page :)

For now you can only create a paste so it will only output either success or error!


(Aug 2, 2014 02:06 PM)Torban Wrote:  You cannot use POST webrequest method because you have CSRF protection.

The API does not have CSRF, only the homepage does.


* - base - Aug 2, 2014

https://mega.co.nz/#!3M9ghJxa!CoSllwSoZL0p5BiXoAX0oV0S3LQJFTQzXIS0K7fSKe0

Download that. Tell me if thats what you wanted


* - Damdomy - Aug 2, 2014

(Aug 2, 2014 02:47 PM)base Wrote:  https://mega.co.nz/#!3M9ghJxa!CoSllwSoZL0p5BiXoAX0oV0S3LQJFTQzXIS0K7fSKe0

Download that. Tell me if thats what you wanted

Hey, the program doesn't work. It just crashes on start.


* - aleeeeeee - Aug 3, 2014

the site don't need an api.
this is the post code and is easy to bypass the csrf (like disperia says) so spam is possible

Code
title=&submit_paste=&csrfToken=RO5nuzQqxDokRbCImwOV0GNalxHbpThxvk%2FWxq9beaM%3D&password=&expiry=0&syntax=cirru&visibility=0&content=text

i don't know php but maybe is better if you insert csrf token in php page that post message and not in home page


* - base - Aug 3, 2014

(Aug 2, 2014 09:54 PM)Damdomy Wrote:  Hey, the program doesn't work. It just crashes on start.

Any error messages? o.o

Also what version of .net framework are you running




https://mega.co.nz/#!eRklhRRR!39nRVwbTQEVgZJktvc7d4kvbwvH4EIUcC3XlXbf_5xQ

I added some additional error handling to see what is causing it to crash.


* - Secret Agent - Aug 3, 2014

(Aug 3, 2014 01:33 AM)aleeeeee Wrote:  the site don't need an api.
this is the post code and is easy to bypass the csrf (like disperia says) so spam is possible

Code
title=&submit_paste=&csrfToken=RO5nuzQqxDokRbCImwOV0GNalxHbpThxvk%2FWxq9beaM%3D&password=&expiry=0&syntax=cirru&visibility=0&content=text

i don't know php but maybe is better if you insert csrf token in php page that post message and not in home page

Then try to bypass CSRF and tell me how you failed

(Aug 1, 2014 05:02 PM)Dispersia Wrote:  I will do this once I get off my next flight (assuming I'm not to tired, I don't move back into my new home until about 12). But on a side note, there isn't a real big need for an API for this. Your csrfToken can be brought out by [<input type="hidden" name="csrfToken" value="Y8mUYbh3yrm4UfDYytRfpKfGa4rDOzR/goSKJq/u/mY"], then just upload title + content + password if wanted into a single request. Would be the same speed. On a side note, you may want to make that a little more secure, I could spam thousands of them a second and fill your server otherwise. However, I will give you that, it looks beautiful. I love what your website looks like. (I just posted one 'test' 'test' just to demonstrate, I can't see any blockers for spam so.)

But ya, I'll write for your api soon. (well hopefully within next 8-10 hours)

On a side note, I like how your pastes are doxes, saying fuck paste.sx or dos scripts. Lol

Good luck with that


* - Damdomy - Aug 3, 2014

(Aug 3, 2014 07:55 AM)base Wrote:  Any error messages? o.o

Also what version of .net framework are you running




https://mega.co.nz/#!eRklhRRR!39nRVwbTQEVgZJktvc7d4kvbwvH4EIUcC3XlXbf_5xQ

I added some additional error handling to see what is causing it to crash.

I was running 4.0. The problem was i didn't run it as admin. Works great now! This is exactly what i want except maybe you can grab the file name with it too :D


* - base - Aug 3, 2014

(Aug 3, 2014 12:02 PM)Damdomy Wrote:  I was running 4.0. The problem was i didn't run it as admin. Works great now! This is exactly what i want except maybe you can grab the file name with it too :D

Alright, I'll add the name as well. If you can modify the API to respond with the link it gave it, I can also add that in (to make it open the paste)




https://mega.co.nz/#!DNNmRLTS!9TFN9inJKc0I0K7PTx909uJ10KoR_yHBM75Jur_ZvlI <- final