Verifying Captcha - post

Q1 - I have been reading through the docs for reCaptcha, and looking at many different forum cases but I am not experienced with API calls at all - I am trying to add a captcha to my custom contact form but I am stuck on the verification step trying to figure out how/where to send the info for verification, and how/where to receive it so I know weather or not the user is verified.
(Side Question: Why is it necessary to validate the token generated by the captcha? Isn't it good enough that you can tell weather or not the puzzle/answer was solved?)
Before the closing head tag:
<script src='https://www.google.com/recaptcha/api.js'></script>
End of my form:
<div class="g-recaptcha" data-sitekey="my-site-key"></div>
I can see the string/token generated by a correct answer when I call:
grecaptcha.getResponse();
Now (as I understand it) I have to verify this string/token which is where I get stuck:
URL: https://www.google.com/recaptcha/api/siteverify
METHOD: POST
DOCS: https://developers.google.com/recaptcha/docs/verify
I am relatively decent with jQuery and vanilla JS but when it comes to API calls I have almost no experience, which is why at this point in the docs I am unsure of how to 1 - form an/the API call (for verification), 2 - where to make the API call from template files-wise, 3 - how to get the response back, or rather how the response comes back.
As I mentioned I am using a Bigcommerce store, and the Google reCaptcha documentation mentioned in several different areas that this step is done on the server-side (or should be). I know that I am fairly restricted in the template files that I can modify - I can view and modify the HTML/CSS/JS files but I have no access to any PHP.
Any help or push in the right direction would be greatly appreciated - at this point I am going in circles finding and trying to read/follow the same docs (Google and other) and forum cases. Thank you.

Trying to answer your questions one by one.
Client side Captcha's are discussed here, please check and note that considering the power of Java Script, client side captchas are not safe.
How reCAPTCHA works: Once someone include below script, google will verify
user.
https://www.google.com/recaptcha/api.js
Writing below attributes in the Form will send data to google first and
response will be added in final post of the current Form with
attribute named g-recaptcha-response :
<div class="g-recaptcha" data-sitekey="your_site_key"></div>
How to validate reCAPTCHA One has to validate this g-recaptcha-response with google. [ NOTE: this is requried becaues
client can send any random value for attribute g-recaptcha-response
without going through Captcha ]
$verifyResponse =
file_get_contents('https://www.google.com/recaptcha/api/siteverify?
secret='.$YOUR_SECRET.'&response='.$_POST['g-recaptcha-response'])
/*allow_url_fopen must be ON if you want to use file_get_contents.
check it using phpinfo();*/
file_put_contents( "logfile", $verifyResponse, FILE_APPEND );
$responseData = json_decode($verifyResponse);
$register_result = 'Robot verification failed, please try again.';
if( $responseData->success )
{
$register_result = 'You are not a bot';
}
else $register_result = 'You are a bot.';
Captcha with HTML/JS/CSS reCaptcha will not work for you if you don't have PHP access.
Puzzles as Captcha Captcha Puzzles are also possible and such captcha's are also available but they are handled on server side.

The reCaptcha verification si to make sure that the answer you received does come from reCaptha server, that the user is not a robot, that it hasn't matured, and that it hasn't been used more than once.
All this is really important to the server running the app, more that the cliente showing the form in order to accept or reject the form to be processed.
This is why the validation has to be done on the server. The client is an unsecure environment that can be tricked so the server cannot trust it.
Besides, to do the validation you need a secret api key. As it is secret it can't be embeded into the client code.
If you don't have access to the php or cannot add and aditional php to do the validation, I don't think you can implement reCaptcha.
EDIT I
The bottom line is that client code (js, jQuery running in a browser) cannot be trusted to do any kind of validation from the server point of view.
For example suppose you implement an input element for the user to enter the result of the sum of two random integers between 0 and 9. Very simple.
In the javascript code in some place there is an:
if(a + b === c){
sendFormToServer();
}else{
reject();
}
Anyone using the browser's developer tools could bypass the "if" and directly call sendFormToServer(). And the server has no way of knowing it.

Related

ruby on rails how to input text into a website after using Nokogiri to open it

I'm writing a unit test for our app for the forget password mutation. The mutation will send the email with the new randomly generated password to the provided email address, and I want to test this. Right now I'm using this to access yopmail.com
doc = Nokogiri::HTML(open("https://yopmail.com/en/"))
puts doc.to_html
On yopmail.com, there's an input box where u input the disposable email to get to the inbox, I just want to know how I would input the disposable email that I generated in my code into yopmail using Nokogiri or whatever other means. Sorry if the explanation isn't clear, I'm not sure how to make this completely make sense. Thank you.
As TTD already mentioned, Nokogiri can only parse HTML / XML but you can't really control the input (although you can alter the HTML itself but that doesn't help for your problem).
What I would do is to avoid entering user input as it will also make your tests a lot more flaky. You can get your mailbox for instance with https://yopmail.com/?<name-of-your-inbox> so you don't have to enter any input.
Unfortunately, yopmail seems to not offer any API. If you're not bound to yopmail, you could for instance try https://rapidapi.com/Privatix/api/temp-mail which offers an API and it make it easier to parse the email results.

STRIPE integration

I'm using the REST Debugger as a first try at working with the stripe API. I can login and perform some basic creation and listing tasks.
When creating a customer the (postal) address elements are described as parameters that are of type 'dictionary'. The docs (https://stripe.com/docs/api/customers/create) refers to them as 'child parameters' with a notation address.line1, address.city etc. I'm lost as to what this means in terms of a Delphi friendly syntax. Anyone got any clues to move me forward? Many thanks
I took a look at the PHP client sources, and I found that the parameters were flattened with a key[subkey] scheme before being sent. So you should use the following parameter names for the address:
address[line1]
address[city]
address[country]
...

Get Email From Hunter.io user Zapier Code Step

I'm trying to use Zapier to call the Hunter.io API and return the first email. Since Zapier is pretty linear I need to be able to return individual emails. When I run this I get the following error "We had trouble sending your test through. Please try again. Error:
You must return a single object or array of objects." I realize I put my API key in there - its only linked to a free version so don't go wild :-).
Any help is appreciated.
fetch('https://api.hunter.io/v2/domain-search?domain=' + inputData.website + '&api_key=11b44ca200c3b3ac0b5cf08091bce3346acd2ed3')
  .then(function(res) {
    return res.json();
  })
  .then(function(json) {
    console.log(json);
    callback(null, json.emails);
  })
  .catch(callback);
David here, from the Zapier Platform team.
Luckily this is an easy fix - it looks like the json that comes back has top-level data and meta keys, the former of which has the emails, you're looking for. If you change your successful callback to
callback(null, json.data.emails)
you should be good to go. Note that subsequent steps will run for each email returned during each run of the zap and no deduplication happens. Make sure whatever's downstream of this can happen a lot without consequences!
Also you'll definitely want to regenerate your API Key once this is resolved. Definitely not something you want floating around. :)

Zapier: How to send data to my Node.js web app from ScheduleOnce using Zapier

Here is my workflow:
Person clicks on my ScheduleOnce link and schedules a meeting
Upon completing the ScheduleOnce booking form, the person clicks the done button
When this done button is clicked the person is redirected to a Node JS web app that displays an application page. This application page needs to be auto-populated with the information from the ScheduleOnce page.
Between step 2 and 3 is where Zapier comes in. I am trying to use Zapier to capture the data from the ScheduleOnce booking, which it is. Then I am trying to use a Zap to send that data to the page the person is redirected to, to auto-populate some of the fields.
I thought using the Code Javascript functionality would work but it does not. So then I was thinking about using the StoreClient option or the API. I am just confused on how to get the flow to work to access the data and auto-populate the fields on the next redirected page.
Some help would be greatly appreciated.
Here is the code I have for the Javascript option:
var store = StoreClient("Secret");
store
.setMany({firstName: inputData.firstName, lastName: inputData.lastName, email: inputData.email, mobilePhone: inputData.mobilePhone, otherPhone: inputData.otherPhone, businessWebsite: inputData.businessWebsite})
.then(function() {
return store.getMany('firstName', 'lastName', 'email', 'mobilePhone', 'otherPhone', 'businessWebsite');
})
.then(function() {
callback();
})
.catch(callback);
David here, from the Zapier Platform team. This is a cool use case and is probably possible. Something you need to remember is that Zapier is running totally separately from the user, so interaction will have to be indirect. Zapier can't redirect your user anywhere, it can just store data in response to a button push.
In your case you can skip everything after the setMany, since you're not trying to use the values in the zap; you just need to store them (and verify that action completed without errors).
var store = StoreClient("Secret");
store
.setMany({firstName: inputData.firstName, lastName: inputData.lastName, email: inputData.email, mobilePhone: inputData.mobilePhone, otherPhone: inputData.otherPhone, businessWebsite: inputData.businessWebsite})
.catch(callback);
You'll need to solve a couple of problems:
Speed. the user will reach your landing page before the zap completes (as it has to make a couple of HTTP round trips and execute code). You'll want to play them a 3 second loading gif, or put a waiting message and allow them to refresh the destination
Populating the page. I'm not sure what the nature of the destination is (best case scenario is that it's a server you control), but something will need to make an http request to store.zapier.com to retrieve the stored data and surface it in the view. This is easy if
Identifying the user. You'll need some way to identify the user getting redirected to the data you stored in StoreClient. If two users fill out the form in quick succession, the second one will currently overwrite the first. Plus, it seems to be semi-sensitive data that you don't just want available to anyone on your site. To that end, you'll probably want to store all of the data as a JSON string keyed by the user's email (or something else unique). That way, when I (the user) finish the form, I'm redirected to yoursite.com/landing?email=david#zapier.com, the backend knows to look for (the david#zapier.com key in store) and can render a view with the correct info.
To that end, I'd tweak the code to the following:
var store = StoreClient("Secret");
store
.set(inputData.email, JSON.stringify({firstName: inputData.firstName, lastName: inputData.lastName, email: inputData.email, mobilePhone: inputData.mobilePhone, otherPhone: inputData.otherPhone, businessWebsite: inputData.businessWebsite}))
.catch(callback);
Hope that points you in the right direction. You're working with a pretty complicated workflow, but I bet you can do it!

Decoding YouTube's error 500 page

This is YouTube's 500 page. Can anyone help decode this information?
<p>500 Internal Server Error<p>
Sorry, something went wrong.
<p>A team of highly trained monkeys has been dispatched to deal with this situation.<p>
If you see them, show them this information:
AB38WENgKfeJmWntJ8Y0Ckbfab0Fl4qsDIZv_fMhQIwCCsncG2kQVxdnam35
TrYeV6KqrEUJ4wyRq_JW8uFD_Tqp-jEO82tkDfwmnZwZUeIf1xBdHS_bYDi7
6Qh09C567MH_nUR0v93TVBYYKv9tHiJpRfbxMwXTUidN9m9q3sRoDI559_Uw
FVzGhjH5-Rd1GPLDrEkjcIaN_C3xZW80hy0VbJM3UI5EKohX35gZNK2aNi_8
Toi9z3L8lzpFTvz5GyHygFFBFEJpoRRJSu3CbH5S2OxXEVo4HgaaBTV7Dx_1
Zs1HZvPqhPIvXg9ifd4KZJiUJDFS8grPLE7bypFsRamyZw-OCVyUHsGQKBwu
77pTtRwpF3hOxYLxM4KnAyiY1N6yrASSWyaeumRDENAoEEe8i8MRxzifqHuR
leatvNMiwsg1pbSl7IIiaKljZaD9UkRms4Kvz1uYUNk4AwXnJ9-Wq44ufMPl
syiHp_LwaeqyuxXykJMl-SA9p05VrJc4kCETUW3Ybp0yTYvVrqggo56A0ofC
OiyAmifQA9pdYVGeumrQtbFlFyDyG9VKNpzn5lqutxFZPsS8xjiILfF3bETD
H4aUb5fT4iERFsEL7S-ClsXiA4yAJdAcNH-OhGg9ipAaIxRRTOR5P1MYx6s6
-OrqgpT5VEaEx2hMpS1afaMd2_F21sxvcz2d8sCpEceHHSfsntTth6talYeD
4l63aUTbbCKV1lHxKWxdUjACFKRobeAvIpcJPcdHSN3CNQI-LlIWIx9jeyBU
tDcL6S6GpRG_Z2of9fmw0LHpVU5hKlQ3lCPd4pVP6J02yrsBi0S9OLoE9jmM
T2FfCvU1sWUCsrZu4-UPflXMyRnFK8aN8DYiwWWE8OvnLQ-LIaRDhjp29u9a
LT6Lh4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R-pJACg
baB20YVezziX-yboCF-uIptCTFNV
(Source: this post on HN)
The debug information contained in the (urlsafe-)base64 blob is likely encrypted.
Think about it from Google's perspective: You would want to display a stack trace, relevant headers of the http request and possibly some internal state of the user session to help a developer debug the situation. On the other hand all that information might contain sensitive information that you don't want the general public to see or that might endanger the user if he copy'n pastes it in a public support forum.
If I was to take a guess of the format I would imagine:
A public identifier of the key used for encryption (their servers could use different keys then)
The debug data encrypted using an authenticated encryption scheme
Additional data for error correction when OCR has to be used
For statistical analysis of the format it would be interesting to sample a lot of these error messages and see if some parts of the message are less random than you would expect from encrypted data (symmetrical encrypted data should follow a uniform distribution).
It looks like you are not the only one who is looking for some secret messages in YouTube error page. It seems that you can decode it using Base64.
Here is how:
http://www.cambus.net/decoding-youtube-http-error-500-message/
In a nutshell:
Sadly, contrary to my expectations, there doesn't seem to be any
hidden message… Screw you, highly trained monkeys!
I guess it is just another Easter Egg similar to 'Goats Teleported' performance counter Google Chrome had:
https://plus.google.com/+RobertPitt/posts/PrqAX3kVapn
But I guess unless you look like this, you can't be 100% sure.
It's entirely possible that this is random padding to avoid the "friendly" IE error pages that show if your error page does not contain more than 512 bytes of HTML. It would be base64 encoded if it were simply random bytes.
Imho this is all about customer care.
Actually there would be no need to send the error/debug message to the customer, because, I guess, it's already handled internally.
So:
why do we see this?
and why do they crypt it?
and is there really no hidden message for us?
Although the error might be handled and resolved internally, this does not necessarily satisfy a customer, who is not able to use the product. They pretty much do crypt by a good reason as this debug message might reveal more than a typical admin is used to.
And also there is no need to hide a message for us. Why? Because we NEVER stop until we find something.
I think:
internally the error is dealt with
external users might have something in hand to tell a technician if necessary and in return can get an approximation of ongoing problem
All in all nothing special about it and i think linking e.g. to the inf. monkey theorem is a bit overspectulated...
Error 500 means google has a problem which can not resolve. So when reporting a bug the most important thing is to prepare reproduction steps. So I tried to find an answer of the question "When this happens?"
I found this post in reddit: https://www.reddit.com/r/youtube/comments/40k858/is_youtube_giving_you_500_internal_server_errors/?utm_source=amp&utm_medium=comment_list
As resume:
It happens on desktops (www...), it works ok on mobile version (m...)
It happens for authenticated users. For anonymous users is working fine.
The problem is resolved after cookies are cleaned.
So I would give a direction: try to find the key in the session cookie. I hope my 2 cents will help.

Resources