jonkpirateboy / Pass-fur-alle

Since Polisens web queueing solution for getting a passport sucks, and it is more or less impossible to book a time, I wrote this small javascript. What it does is that it automates the searching for a bookable time. In the file you just change the constants to your information and away you go. :)
GNU General Public License v3.0
376 stars 96 forks source link

Confirm you are a human #42

Closed nattzp closed 2 years ago

nattzp commented 2 years ago

They just added a text field where you have to type in letters from a picture to confirm you are a human. Is there any way around this? Maybe edit the script so it starts running after you have typed in the letters, which you only have to do one time in the beginning?

barhom commented 2 years ago

this confirmation was just added

geekteq commented 2 years ago

I saw it on the confirmation page as well but it may have been moved.

geekteq commented 2 years ago

Confirmed it's on the confirmation page as well. So I'm assuming we need to manually confirm as well Skärmavbild 2022-03-31 kl  17 08 55

haegg78 commented 2 years ago

They have also blocked number of requests now

Skärmavbild 2022-03-31 kl  17 09 58
geekteq commented 2 years ago

They have also blocked number of requests now Skärmavbild 2022-03-31 kl 17 09 58

I get through this blockage by using Firefox instead of Chrome so I'm assuming they have something that's set for us to block the user agent.

jonkpirateboy commented 2 years ago

I’ll take a look at this later.

geekteq commented 2 years ago

I’ll take a look at this later.

Thanks, I'm not assuming it will be an easy fix an a lot more manual if a fix comes. We'll see. most of my friends and their friends have gotten their times now. They do seem to have some kind of block on chromedriver now as well. As we get redirected to the last "too many connections page" while if I switch to firefox I get through. Thanks again, for the script as it has been and the updates, and if the time is up then we'll hope they'll block the people who does it for malevolent reasons as well (to make money)

justinphelps commented 2 years ago

Can confirm that using the Firefox/geckdriver instead of Chrome fixes the "För många anprop" issue, but the Captcha issue still blocks .

addellll commented 2 years ago

Just to add some value for this problem maybe Deathbycaptcha/Anti-Captcha paid API can solve this?

Big thank you @jonkpirateboy for this tool. And it seams that I was lucky since I got time 2 days ago before this captcha BS.

jonkpirateboy commented 2 years ago

https://passfuralle.se/2022/03/nya-funktioner-pa-tidsbokningen/

d00ze commented 2 years ago

@jonkpirateboy Kämpa på, jag han fick lägga till en funktion för paus i ditt tidigare script. Men fick en tid idag och passet är fixat. Tack för ditt arbete.

Leopenardo commented 2 years ago

@jonkpirateboy Kämpa på, jag han fick lägga till en funktion för paus i ditt tidigare script. Men fick en tid idag och passet är fixat. Tack för ditt arbete.

Skulle du snälla kunna hjälpa mig? Åker utomlands om 2 månader så är ganska akut med just pass.. All hjälp uppskatas upp till skyarna!!

kajetan-kazimierczak commented 2 years ago
andreasmq commented 2 years ago

faking useragent with

ua = UserAgent()
user_agent = ua.ff
options.add_argument(f'user-agent={user_agent}')

does result in the "för många anrop" page

Switching to firefox driver instead of chrome gets to the captcha.

LucGosso commented 2 years ago

Polisens captcha, detta var lite ironiskt

image

nattzp commented 2 years ago
  • Disable javascript to make the captcha go away.
  • Stop DDOSing the poor booking site (set time between calls to 10-15 seconds or longer) to avoid the "för många anrop"

how do i set the time between calls?

nattzp commented 2 years ago

Solved the captcha issue by adding a sleep(10) before continuing to next page on the captcha page, allows you to manually insert captcha letters. However, it seems that they have changes the layout for the times available now so the code doesn't work anyway. Could this be updated to match the new layout?

UgisL commented 2 years ago

For me, it seems that the time choice works only with javascript turned on ... Would it be possible to dynamically turn on / off the javascript permission?

I.e., start with turned off (first page), when we are at checkpoint that we live in Sweden, turn it back on, then after the time choice turn it off (need to press next 2 times, because after the choice of time, the captcha is immediately loaded and first time around it complains about not filling it in ...

When the script was working, I have been searching for time further away from now (Skatteverket has not registered the name of my newborn just yet, so I can not rush to polisen any time now), between beginning of May and mid-June, was not lucky yet.

Andows commented 2 years ago

It is also a captcha on the confirm booking page now.

mryner228 commented 2 years ago

ok, so I seem to be able to get the script running in firefox. Set a delay to be able to fill in captcha on the first page. First available time seems to be an issue, that just halts. Setting 'firstDate' to false starts the search at least.

With that set to False I manage to go through to the booking. Tried with dates in Oct (so way late but just to try). But for me everything except 'firstDate' seems to work in firefox.

mryner228 commented 2 years ago

With firstDate = true scripts only seems to run twice and then halt.

geekteq commented 2 years ago

ok, so I seem to be able to get the script running in firefox. Set a delay to be able to fill in captcha on the first page. First available time seems to be an issue, that just halts. Setting 'firstDate' to false starts the search at least.

With that set to False I manage to go through to the booking. Tried with dates in Oct (so way late but just to try). But for me everything except 'firstDate' seems to work in firefox.

Do share the code if you want to. Have my last 4 people to get through and even if it's manual labor I'd like to help them out ;)

mryner228 commented 2 years ago

Haven't changed any code really. Just called on Firefox instead of Chrome with Gecko. Then added a delay on the first page so you have time to enter the captcha letters. After that just let it roll. Not as effective as firstDate but.

This is only change in code really apart from calling on firefox. So time.sleep(10) instead of (1)

 # Click the first button
    startButton = web.find_element(by=By.XPATH, value='//*[@class="btn btn-primary btn-large disable-on-save"]')
    startButton.click()
    time.sleep(10)
mryner228 commented 2 years ago

Seem to drop after a couple of loops though... not sure why and that seems to happen after 2 loops on 'firstDate' instead of 5-6 going through a range of dates...

fltman commented 2 years ago

So I changed the script to use firefox.

web = webdriver.Firefox("/Applications/Firefox.app/Contents/MacOS/") Then, before entering the location I went to about:config in the firefox window, searched for javascript and disabled it. And it just worked... for about 20 minutes or so then firefox was blocked (to many calls).

I can still access the site from other browsers and devices so the lock isn't based on IP alone. Cleaning the cookies and changing the useragent didn't do it either. This means that the to many calls block must be based on more things.

Perhaps trying to run the session through a TOR proxy in combination with the things above could bypass it?

fltman commented 2 years ago

Nope, didn't work through a TOR proxy either. So they detect and log something else about the client.

MarcusWidle commented 2 years ago

Just to add some value for this problem maybe Deathbycaptcha/Anti-Captcha paid API can solve this?

Big thank you @jonkpirateboy for this tool. And it seams that I was lucky since I got time 2 days ago before this captcha BS.

Anti-Captcha or any other services wouldn't really help as none of them are supports mtcaptcha.

ispjstfu commented 2 years ago

I just made it work by adding the following code after the #Accept-section in the code

        # MANUALLY solve verification
        input("Lös verifieringen manuellt och klicka på enter när du är klar.")
        manualverifyNextButton = web.find_element(by=By.XPATH, value='//*[@id="Main"]/form/div[2]/input')
        manualverifyNextButton.click()
        time.sleep(1)

This stops the script indefinitely so we can input the captcha manually, and then we can just hit enter when ready to move on. Works perfectly for me.

ispjstfu commented 2 years ago

I just made it work by adding the following code after the #Accept-section in the code

        # MANUALLY solve verification
        input("Lös verifieringen manuellt och klicka på enter när du är klar.")
        manualverifyNextButton = web.find_element(by=By.XPATH, value='//*[@id="Main"]/form/div[2]/input')
        manualverifyNextButton.click()
        time.sleep(1)

This stops the script indefinitely so we can input the captcha manually, and then we can just hit enter when ready to move on. Works perfectly for me.

Now I've also added a fix for the second verification step after a time is found, plus a click that the "important information" was read so that the script can move on and confirm the booking.

Made a pull request for my fixes now.

tedpelas commented 2 years ago

Anyone else also been getting these errors recently?

504 Gateway Time-out
The server didn't respond in time.
danwie commented 2 years ago

Can confirm that using the Firefox/geckdriver instead of Chrome fixes the "För många anprop" issue, but the Captcha issue still blocks .

Could you please share the code needed to use Firefox/geckdriver?

rypto commented 2 years ago

So I changed the script to use firefox.

web = webdriver.Firefox("/Applications/Firefox.app/Contents/MacOS/") Then, before entering the location I went to about:config in the firefox window, searched for javascript and disabled it. And it just worked... for about 20 minutes or so then firefox was blocked (to many calls).

I can still access the site from other browsers and devices so the lock isn't based on IP alone. Cleaning the cookies and changing the useragent didn't do it either. This means that the to many calls block must be based on more things.

Perhaps trying to run the session through a TOR proxy in combination with the things above could bypass it?

Do you replace some other lines in the code then or how do you do it?, I'm running Ubuntu and have installed geckodriver

geekteq commented 2 years ago

Now I've also added a fix for the second verification step after a time is found, plus a click that the "important information" was read so that the script can move on and confirm the booking.

Tack, kör med dessa nu men la till "boka ny tid" knappen manuellt för de verkade känna av om den klickades "programmatiskt" eller inte och skickade mig till "för många anrop" - klickar jag den själv så kommer jag förbi.

Fyller Captchan och sen åker jag. Eftersom det kan ta en stund så tankade jag in "playsound" när det är dags för sista captchan också. Skrämde frun när en "aaaauuuugahhhh" spelades två gånger igår kväll - hann fram, körde igenom captchan så nu har jag bara två kompisar kvar på listan innan jag kan strunta i det här :)

danwie commented 2 years ago

Now I've also added a fix for the second verification step after a time is found, plus a click that the "important information" was read so that the script can move on and confirm the booking.

Tack, kör med dessa nu men la till "boka ny tid" knappen manuellt för de verkade känna av om den klickades "programmatiskt" eller inte och skickade mig till "för många anrop" - klickar jag den själv så kommer jag förbi.

Fyller Captchan och sen åker jag. Eftersom det kan ta en stund så tankade jag in "playsound" när det är dags för sista captchan också. Skrämde frun när en "aaaauuuugahhhh" spelades två gånger igår kväll - hann fram, körde igenom captchan så nu har jag bara två kompisar kvar på listan innan jag kan strunta i det här :)

Tack - det var den informationen jag behövde. Nu snurrar det hos mig här också. Men spela upp ljud när sista captchan dyker upp, hur fixade du det?

geekteq commented 2 years ago

Tack - det var den informationen jag behövde. Nu snurrar det hos mig här också. Men spela upp ljud när sista captchan dyker upp, hur fixade du det?

Litet hack.. I början hämtar jag in

from playsound import playsound (behöver köra "pip3 install playsound" före)

Vid den sista "captchan"

# MANUALLY solve verification again input("Lös även denna verifieringen manuellt och klicka på enter när du är klar.") manualverify2NextButton = web.find_element(by=By.XPATH, value='//*[@id="Main"]/form/div[2]/input') manualverify2NextButton.click() time.sleep(1)

så lägger jag in

# MANUALLY solve verification again playsound('warning.mp3') #vilken mp3a som helst funkar o ska ligga i samma bibliotek input("Lös även denna verifieringen manuellt och klicka på enter när du är klar.") manualverify2NextButton = web.find_element(by=By.XPATH, value='//*[@id="Main"]/form/div[2]/input') manualverify2NextButton.click() time.sleep(1)

Får inte radbrytningar på rätt ställe men hoppas du fattar :)

dio99 commented 2 years ago

@geekteq tjo testar detta hack men får endå upp den bilden när man ska clicka på boka tid och när ja klickar på den så blir det den blocken att man försöker för ofta

geekteq commented 2 years ago

@geekteq tjo testar detta hack men får endå upp den bilden när man ska clicka på boka tid och när ja klickar på den så blir det den blocken att man försöker för ofta

"Works for me" - men kör Mac-lösning så vet inte vad som kan diffa. Uppdaterat allt chrome, chromedriver etc igår så kan ha med saken att göra antar jag - men vet inte..

dio99 commented 2 years ago

@geekteq tjo testar detta hack men får endå upp den bilden när man ska clicka på boka tid och när ja klickar på den så blir det den blocken att man försöker för ofta

"Works for me" - men kör Mac-lösning så vet inte vad som kan diffa. Uppdaterat allt chrome, chromedriver etc igår så kan ha med saken att göra antar jag - men vet inte..

hmm linux testar ja med.. ok ska se om ja kan dra ner nyare driver då för chrome. kör default deb paket

UgisL commented 2 years ago

Finally, got also our time. I used Chrome, with these load options: option = webdriver.ChromeOptions() option.add_argument('--disable-blink-features=AutomationControlled') web = webdriver.Chrome(executable_path='/usr/bin/chromedriver',options=option)

And commented out in the script automatic click of the first button, and also had to manually enter both captchas. I used 20s sleep between different "Find first available time" clicks. Then I implemented email notification, when I had to run to the computer and enter the final captcha and finish the booking. Email call looks like (will stop working with google after end of May, will have to use more complex authentification): import smtplib, ssl port = 465 # For SSL password = "test@1234" context = ssl.create_default_context()

with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server: server.login("[yourmail]@gmail.com", password) server.sendmail("[yourmail2]@gmail.com", "[yourmail2]@gmail.com", """\ Subject: Finish passport booking!

I found a good time!!!""")

Good luck, everyone!

geekteq commented 2 years ago

@UgisL nice one. Makes me thing I should've gone with "pushover" rather than "playsound" but only have one friend more to help so can't do it.

@jonkpirateboy i don't know if it's beer-ware but do let me know how I can thank you with more than "thank you" for these hacks now that I'm almost done 🥇

dio99 commented 2 years ago

Finally, got also our time. I used Chrome, with these load options: option = webdriver.ChromeOptions() option.add_argument('--disable-blink-features=AutomationControlled') web = webdriver.Chrome(executable_path='/usr/bin/chromedriver',options=option)

And commented out in the script automatic click of the first button, and also had to manually enter both captchas. I used 20s sleep between different "Find first available time" clicks. Then I implemented email notification, when I had to run to the computer and enter the final captcha and finish the booking. Email call looks like (will stop working with google after end of May, will have to use more complex authentification): import smtplib, ssl port = 465 # For SSL password = "test@1234" context = ssl.create_default_context()

with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server: server.login("[yourmail]@gmail.com", password) server.sendmail("[yourmail2]@gmail.com", "[yourmail2]@gmail.com", """ Subject: Finish passport booking!

I found a good time!!!""")

Good luck, everyone!

changed like u did and it seems running now, but in what page did u stop posting some info manually ? im in sektion now where u choose sök tid

BloodDragon05 commented 2 years ago

How do you guys get pass "Boka tid"-button? As soon as i press that button i get sent to "För många anrop"...

geekteq commented 2 years ago

How do you guys get pass "Boka tid"-button? As soon as i press that button i get sent to "För många anrop"...

I don't know tbh. I click the button manually and it doesn't tell me "för många anrop", if I try it without doing it manually I get slapped in the face with "För många androp". As mentioned I have updated all my systems and I'm running MacOS but I don't know if that is the difference.

BloodDragon05 commented 2 years ago

How do you guys get pass "Boka tid"-button? As soon as i press that button i get sent to "För många anrop"...

I don't know tbh. I click the button manually and it doesn't tell me "för många anrop", if I try it without doing it manually I get slapped in the face with "För många androp". As mentioned I have updated all my systems and I'm running MacOS but I don't know if that is the difference.

What version om ChromeDriver are you using? I am on windows and followed every step but maybe I've done something wrong... I press the button manually since the script won't press it...

geekteq commented 2 years ago

What version om ChromeDriver are you using? I am on windows and followed every step but maybe I've done something wrong... I press the button manually since the script won't press it...

100.0.4896.60

nattzp commented 2 years ago

Can someone who has working code publish their entire .py file? I am in desperate need hehe

BloodDragon05 commented 2 years ago

What version om ChromeDriver are you using? I am on windows and followed every step but maybe I've done something wrong... I press the button manually since the script won't press it...

100.0.4896.60

Have that too... Get kicked out everytime....

geekteq commented 2 years ago

Here's mine without "playsound"

jonkpirateboy commented 2 years ago

Works great @geekteq! Do you want to add this as a Pull request?

geekteq commented 2 years ago

Works great @geekteq! Do you want to add this as a Pull request?

My first pull request so don't be too harsh on me :)