Notice: My personal stance on AI generated artwork. Retweet and share if you agree. Let us discuss, and not immediately scream bloody murder.

Now Viewing: Error 403?
Keep it civil, do not flame or bait other users. If you notice anything illegal or inappropriate being discussed, contact an administrator or moderator.

Jerl - Group: The Real Administrator - Total Posts: 6706
user_avatar
Posted on: 10/24/15 09:53AM

Make sure you're sending the pass hash, not the password itself. The only time the site will accept a raw password is when you're logging in.

You can get the pass hash from the cookies the site will set once you're logged in. I highly recommend having your app actually log in instead of trying to send arbitrary values as cookies in the HTTP header.



Sanitia - Group: Member - Total Posts: 3
user_avatar
Posted on: 10/25/15 05:32PM

Thanks for the help, all!

Here's what I had to add to make my Chrome extension work:
pastebin.com/zL85xug6



Strahan - Group: Member - Total Posts: 81
user_avatar
Posted on: 10/25/15 09:30PM

I've been tearing my hair out with this today. I got it working, but only if I manually set the cookie headers in my request using values I grabbed from a WireShark capture of a browser session. As Jerl recommended, I'm trying to rework my app to do proper log in and get the cookies from Gelb instead. Anyone good with C#? This is my code:

string formUrl = "www.gelbooru.com/index.ph...=login&code=00";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(formUrl);
req.Referer = formUrl;
req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0";
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes("user=Strahan&pass=xxxxxx&submit=Log%20In");
req.ContentLength = bytes.Length;
using (Stream os = req.GetRequestStream()) os.Write(bytes, 0, bytes.Length);
WebResponse resp = req.GetResponse();
WebHeaderCollection hdr = resp.Headers;
foreach (string headkey in hdr.Keys) Write(headkey + ": " + hdr[headkey]);

I watched the login process using my browser with WireShark. This was the outgoing transmission: www.miscfiles.org/gelb-browser-out.jpg and the incoming was www.miscfiles.org/gelb-browser-in.jpg

So I ran my app and triggered that code, and it looks like it worked, judging from the inbound response from Gelb. www.miscfiles.org/gelb-app-out.jpg and www.miscfiles.org/gelb-app-in.jpg

However... the code above is set to iterate though the headers and write to my textbox. From what I understand, cookies are sent as header objects titled "Set-Cookie". This is all I got in the textbox though:

Transfer-Encoding: chunked
Connection: keep-alive
Content-Type: text/html
Date: Mon, 26 Oct 2015 02:27:37 GMT
Server: nginx/1.8.0

I can see the cookies Gelb is giving me in Wireshark, but my WebResponse object doesn't see them. Any ideas what I should do? I don't want to keep using the ghetto way if I can avoid it. Thanks.



Jerl - Group: The Real Administrator - Total Posts: 6706
user_avatar
Posted on: 10/25/15 10:15PM

I have working code for logging in on Gelbooru in C#. I'll share it when I get home.

EDIT:

pastebin.com/y4wFrZXb

This is the class I use for logins. You can use this class in your code or just examine what I did, whatever you prefer.

Login() returns a CookieContainer object. You can add this CookieContainer object to your HttpWebRequest object like this:

HttpWebRequest request = ...etc
bool loginSuccess;
CookieContainer cookies = Jerl.GelbooruActionablesLibrary.Account.Login("username", "password", out loginSuccess);
request.CookieContainer = cookies;

You keep this CookieContainer and use it the entire time your program runs. I highly recommend using CookieContainers over trying to parse and store cookies yourself. I log in once when the program starts and pass a reference to the CookieContainer to each class I create that may need it and store it as a property in that class.

Since CookieContainers are built in to the HttpWebResponse class, it's possible that they strip them out of the headers. I haven't actually researched this, so don't quote me on it, but that's a possibility for why you aren't able to access them the way you're trying to.



Strahan - Group: Member - Total Posts: 81
user_avatar
Posted on: 10/26/15 11:25AM

Ahhhhhhh thank you :) Yes, they are apparently stripping them from the headers. Once I looked at your code, I did what you did and setup a CookieContainer and now I'm getting my login cookies fine and my app functions properly now. Awesome. Thanks again!



Jerl - Group: The Real Administrator - Total Posts: 6706
user_avatar
Posted on: 10/26/15 12:22PM

No problem.



tommer - Group: Member - Total Posts: 2
user_avatar
Unexpected traffic
Posted on: 10/29/15 12:32PM

Hey, that unusually high level of traffic may or may not have been me.

I uh, was learning about C# and decided to try to make a bulk-downloader for gelbooru using the provided API's, while I was repeatedly testing it I must have pulled about 20gb of data down in a couple days around 25 Sept. I had no idea that just downloading images would cause the site to slow down though, I'd kind of assumed it'd be fine because gelbooru is a big site and it'd probably just throttle me anyway but I guess I was wrong

I won't develop that downloader any more though if it is causing problems, it was just a toy, and I never released it into the wild so only I have a copy of it anyway, did not mean for it to be something that would result in everyone not being able to use gelbooru or something.

I'm sorry if it was me guys :(



jedi1357 - Group: Moderator - Total Posts: 5777
user_avatar
Posted on: 10/29/15 12:44PM

I would recommend Image Host Grabber (assuming it still works with our updated API), a program we know won't kill our site. You shouldn't grab more than 15 simultaneous downloads or 20GB in a week. So, yea, you might have been pushing it a little.

That said, I have no way of telling if it was even you who where causing a problem. It might have been something completely unrelated.



tommer - Group: Member - Total Posts: 2
user_avatar
Posted on: 10/29/15 12:48PM

My downloader was downloading images one at a time, there was no simultaneous downloading occuring it was programmed to wait until the download finishes before starting the next one.. I don't really want an alternative program, because I'm not really interested in bulk downloading images from gelbooru, I actually just made it to learn about c# lol



jedi1357 - Group: Moderator - Total Posts: 5777
user_avatar
Posted on: 10/29/15 12:53PM

Fine. Just so you know, we are not really a big site.

I don't know how many resources we have but I wouldn't be surprised if it all fits into a single shelf at the server farm.



add_replyAdd Reply


1234 5 6789