로봇이 양식을 자동으로 채우는 것을 방지하는 방법은 무엇입니까?
자동으로 생성되는 입력을 방지 할 수있는 충분한 스팸 방지 메커니즘을 마련하려고합니다. 나는 captcha, 1 + 1 =?과 같은 기술을 읽었습니다. 물건은 잘 작동하지만 응용 프로그램의 무료 빠른 사용을 방해하는 추가 단계를 제공합니다 (나는 그런 것을 찾고 있지 않습니다).
모든 양식에 숨겨진 필드를 설정하려고 시도했지만 display: none;
양식 필드 ID를 추적하고 단순히 채우지 않도록 스크립트를 구성 할 수 있다고 확신합니다.
좋은 자동 양식 채우기 방지 방법을 구현 / 알고 있습니까? HTML 및 / 또는 서버 측 처리로 원활하게 수행 할 수 있고 (거의) 방탄이 될 수있는 것이 있습니까? (JS 없이는 단순히 비활성화 할 수 있습니다).
나는 이것을 위해 세션에 의존하지 않으려 고 노력하고있다 (즉, 과부하를 방지하기 위해 버튼을 클릭하는 횟수를 세는 것).
스팸 방지를 해결하는 구현하기 쉽지만 완벽하지는 않지만 (특히 "특정"공격에 대한) 스팸 방지 방법은 양식 제출과 페이지로드 사이의 시간을 추적하는 것입니다.
봇은 페이지를 요청하고 페이지를 구문 분석하고 양식을 제출합니다. 이것은 빠릅니다.
사람은 URL을 입력하고, 페이지를로드하고, 페이지가 완전히로드 될 때까지 기다린 다음, 아래로 스크롤하고, 콘텐츠를 읽고, 양식에 주석 / 채우기 여부를 결정하고, 양식을 채우는 데 시간이 필요하고, 제출합니다.
시간의 차이는 미묘 할 수 있습니다. 쿠키없이이 시간을 추적하는 방법에는 서버 측 데이터베이스가 필요합니다. 이는 성능에 영향을 미칠 수 있습니다.
또한 임계 시간을 조정해야합니다.
나는 실제로 간단한 Honey Pot 필드가 잘 작동한다는 것을 알았습니다. 대부분의 봇 은 필요한 필드 유효성 검사기를 살펴보고자하는 모든 양식 필드를 채 웁니다 .
http://haacked.com/archive/2007/09/11/honeypot-captcha.aspx
텍스트 상자를 만들고 자바 스크립트로 숨긴 다음 서버 에서 값이 비어 있는지 확인 하면 99 %의 로봇이 제거되고 사용자의 99 %는 전혀 불만을 느끼지 않습니다. 자바 스크립트를 비활성화 한 나머지 1 %는 여전히 텍스트 상자를 볼 수 있지만 이러한 경우에 대해 "이 필드를 비워 두십시오"와 같은 메시지를 추가 할 수 있습니다 (모두 신경 쓰는 경우).
(또한 필드에서 style = "display : none"을 수행하면 로봇이 그것을보고 필드를 버리는 것이 너무 쉽다는 점에 유의하십시오. 이것이 제가 자바 스크립트 접근 방식을 선호하는 이유입니다).
어떤 경우 - 봇이되지 않은 발견 않는 form
전혀를?
3 가지 예 :
1. AJAX를 사용하여 양식 삽입
JS가 비활성화되어 있고 양식을 보거나 제출할 수없는 사용자에게 괜찮다면 ... 언제든지을 사용하여 알릴 수 있습니다 <noscript><p class="error">ERROR: The form could not be loaded. Please, re-enable JavaScript in your browser to fully enjoy our services.</p></noscript>
. 보다,
- 를 작성
form.html
하고 배치form
내부<div id="formContainer">
요소를. - 해당 양식을 호출해야하는 페이지 내부에서 비어있는
<div id="dynamicForm"></div>
jQuery를 사용하십시오.
$("#dynamicForm").load("form.html #formContainer");
2. JS를 사용하여 양식 작성
// THE FORM
var $form = $("<form/>", {
appendTo : $("#formContainer"),
class : "myForm",
submit : AJAXSubmitForm
});
// EMAIL INPUT
$("<input/>",{
name : "Email", // Needed for serialization
placeholder : "Your Email",
appendTo : $form,
on : { // Yes, the jQuery's on() Method
input : function() {
console.log( this.value );
}
}
});
// MESSAGE TEXTAREA
$("<textarea/>",{
name : "Message", // Needed for serialization
placeholder : "Your message",
appendTo : $form
});
// SUBMIT BUTTON
$("<input/>",{
type : "submit",
value : "Send",
name : "submit",
appendTo : $form
});
function AJAXSubmitForm(event) {
event.preventDefault(); // Prevent Default Form Submission
// do AJAX instead:
var serializedData = $(this).serialize();
alert( serializedData );
$.ajax({
url: '/mail.php',
type: "POST",
data: serializedData,
success: function (data) {
// log the data sent back from PHP
console.log( data );
}
});
}
.myForm input,
.myForm textarea{
font: 14px/1 sans-serif;
box-sizing: border-box;
display:block;
width:100%;
padding: 8px;
margin-bottom:12px;
}
.myForm textarea{
resize: vertical;
min-height: 120px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="formContainer"></div>
3. 봇-베이트 입력
(같은 봇 정말 같은) 건방진의 같은 입력 요소 :
<input
type="text"
name="email"
id="email"
placeholder="Your email"
autocomplete="nope"
tabindex="-1" />
그들은 그들이하는 것처럼 어떤 값을 입력하게되어 기뻐할 것입니다. dsaZusil@kddGDHsj.com
(위의 HTML을 사용한 후) CSS를 사용하면 다음과 같습니다.
input[name=email]{ /* bait input */
/*
don't use display:none or visibility:hidden
cause that will not fool the bot
*/
position:absolute;
left:-2000px;
}
지금 당신의 입력은 사용자가 볼 수없는 것을, 당신의 것을 PHP 기대 $_POST["email"]
비어 있어야합니다 (값없이)! 그렇지 않으면 양식을 제출하지 마십시오.
지금 할 수있는 모든 오유 필요가 만드는 것입니다 다른 입력을 같은 <input name="sender" type="text" placeholder="Your email">
(!) 후 "봇 미끼" 실제 사용자의 이메일 주소를 입력.)
감사의 말 :
Developer.Mozilla-양식 자동 완성 끄기
StackOverflow-Tabindex 무시
내가 한 일은 숨겨진 필드를 사용하고 그 위에 타임 스탬프를 넣은 다음 PHP를 사용하여 서버의 타임 스탬프와 비교하는 것입니다.
15 초보다 빠르다면 (폼의 크기에 따라 다름) 그것은 봇이었습니다.
이 도움을 바랍니다
스팸을 사실상 제거하는 매우 효과적인 방법은 "양식을 제출하려면이 텍스트를 제거하십시오!"와 같은 텍스트가 포함 된 텍스트 필드를 만드는 것입니다. 양식을 제출하려면 해당 텍스트를 제거해야합니다.
양식 유효성 검사시 텍스트 필드에 원본 텍스트 또는 해당 사안에 대한 임의의 텍스트가 포함 된 경우 양식을 제출하지 마십시오. 봇은 양식 이름을 읽고 이름 및 이메일 필드를 자동으로 채울 수 있지만 제출하기 위해 실제로 특정 필드에서 텍스트를 제거해야하는지 알 수 없습니다.
저는이 방법을 회사 웹 사이트에 구현했으며 매일받는 스팸을 완전히 제거했습니다. 실제로 작동한다!
공백으로 남아 있어야하는 배경과 동일한 색상의 텍스트 필드 입력 상자를 만드는 것은 어떻습니까? 이렇게하면 봇 읽기 디스플레이 문제를 해결할 수 있습니다.
reCAPTCHA는 책을 디지털화하는 데 도움이되는 무료 안티 봇 서비스입니다.
Google이 인수했습니다 (2009 년) :
또한보십시오
이러한 스팸봇 중 상당수는 웹을 배회하는 서버 측 스크립트 일뿐입니다. 양식 요청이 전송되기 전에 일부 자바 스크립트를 사용하여 양식 요청을 조작하여 많은 문제를 해결할 수 있습니다 (예 : 일부 클라이언트 변수에 따라 추가 필드 설정). 이것은 완전한 솔루션이 아니며 많은 문제를 일으킬 수 있지만 (예 : 자바 스크립트가없는 사용자, 모바일 장치 등) 공격 계획의 일부가 될 수 있습니다.
다음은 간단한 예입니다 ...
<script>
function checkForm()
{
// When a user submits the form, the secretField's value is changed
$('input[name=secretField]').val('goodValueEqualsGoodClient');
return true;
}
</script>
<form id="cheese" onsubmit="checkForm">
<input type="text" name="burger">
<!-- Check that this value isn't the default value in your php script -->
<input type="hidden" name="secretField" value="badValueEqualsBadClient">
<input type="submit">
</form>
PHP 스크립트 어딘가에 ...
<?php
if ($_REQUEST['secretField'] != 'goodValueEqualsGoodClient')
{
die('you are a bad client, go away pls.');
}
?>
또한 캡 차는 훌륭하며 스팸에 대한 최상의 방어 수단입니다.
아직 아무도이 방법을 언급하지 않은 것에 놀랐습니다.
- 페이지에 작고 숨겨진 이미지를 포함하세요.
- 이 이미지를 제공 할 때 쿠키를 배치하십시오.
- 양식 제출을 처리 할 때 쿠키를 확인하십시오.
장점 :
- 사용자와 개발자에게 편리함
- 믿을만한 것 같다
- 자바 스크립트 없음
단점 :
- 하나의 HTTP 요청을 추가합니다.
- 클라이언트에서 쿠키를 활성화해야합니다.
예를 들어,이 방법은 WordPress 플러그인 Cookies for Comments에서 사용 됩니다.
무엇이든 에뮬레이트 할 수있는 헤드리스 브라우저 (예 : phantomjs)의 출현으로 다음과 같이 가정 할 수 없습니다 .
- 스팸 봇은 자바 스크립트를 사용하지 않습니다.
- 마우스 이벤트를 추적하여 봇을 감지 할 수 있습니다.
- 필드가 시각적으로 숨겨져 있다는 것을 알 수 없습니다.
- 그들은 제출하기 전에 주어진 시간을 기다리지 않을 것입니다.
그것이 사실 이었다면 더 이상 사실이 아닙니다.
사용자 친화적 인 솔루션을 원하지 않는 경우 멋진 "나는 스패머입니다" 제출 버튼을 제공하십시오 .
<input type="submit" name="ignore" value="I am a spammer!" />
<input type="image" name="accept" value="submit.png" alt="I am not a spammer" />
물론 두 개의 이미지 input[type=image]
버튼으로 재생할 수 있습니다. 각로드 후 순서, 대체 텍스트, 이미지의 내용 (및 크기) 또는 버튼의 순서를 변경할 수 있습니다 name
. 서버 작업이 필요합니다.
<input type="image" name="random125454548" value="random125454548.png"
alt="I perfectly understand that clicking on this link will send the
e-mail to the expected person" />
<input type="image" name="random125452548" value="random125452548.png"
alt="I really want to cancel the submission of this form" />
접근성을 위해 올바른 대체 텍스트를 입력해야하지만 스크린 리더 사용자에게는 긴 문장이 봇으로 간주되는 것보다 낫다고 생각합니다.
매우 간단한 방법은 같은 필드를 제공 <textarea style="display:none;" name="input"></textarea>
하고이 필드 가 채워진 모든 응답을 삭제하는 것입니다.
또 다른 접근 방식은 Javascript를 사용하여 전체 양식 (또는 필드 이름 만)을 생성하는 것입니다. 소수의 봇이 실행할 수 있습니다.
Anyway, you won't do much against live "bots" from Taiwan or India, that are paid $0.03 per one posted link, and make their living that way.
I have a simple approach to stopping spammers which is 100% effective, at least in my experience, and avoids the use of reCAPTCHA and similar approaches. I went from close to 100 spams per day on one of my sites' html forms to zero for the last 5 years once I implemented this approach.
It works by taking advantage of the e-mail ALIAS capabilities of most html form handling scripts (I use FormMail.pl), along with a graphic submission "code", which is easily created in the most simple of graphics programs. One such graphic includes the code M19P17nH and the prompt "Please enter the code at left".
This particular example uses a random sequence of letters and numbers, but I tend to use non-English versions of words familiar to my visitors (e.g. "pnofrtay"). Note that the prompt for the form field is built into the graphic, rather than appearing on the form. Thus, to a robot, that form field presents no clue as to its purpose.
The only real trick here is to make sure that your form html assigns this code to the "recipient" variable. Then, in your mail program, make sure that each such code you use is set as an e-mail alias, which points to whatever e-mail addresses you want to use. Since there is no prompt of any kind on the form for a robot to read and no e-mail addresses, it has no idea what to put in the blank form field. If it puts nothing in the form field or anything except acceptable codes, the form submission fails with a "bad recipient" error. You can use a different graphic on different forms, although it isn't really necessary in my experience.
Of course, a human being can solve this problem in a flash, without all the problems associated with reCAPTCHA and similar, more elegant, schemes. If a human spammer does respond to the recipient failure and programs the image code into the robot, you can change it easily, once you realize that the robot has been hard-coded to respond. In five years of using this approach, I've never had a spam from any of the forms on which I use it nor have I ever had a complaint from any human user of the forms. I'm certain that this could be beaten with OCR capability in the robot, but I've never had it happen on any of my sites which use html forms. I have also used "spam traps" (hidden "come hither" html code which points to my anti-spam policies) to good effect, but they were only about 90% effective.
I'm thinking of many things here:
- using JS (although you don't want it) to track mouse move, key press, mouse click
- getting the referral url (which in this case should be one from the same domain) ... the normal user must navigate through the website before reaching the contact form: PHP: How to get referrer URL?
- using a $_SESSION variable to acquire the IP and check the form submit against that list of IPs
- Fill in one text field with some dummy text that you can check on server side if it had been overwritten
- Check the browser version: http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php.html ... It's clear that a bot won't use a browser but just a script.
- Use AJAX to send the fields one by one and check the difference in time between submissions
- Use a fake page before/after the form, just to send another input
Another option instead of doing random letters and numbers like many websites do, is to do random pictures of recognizable objects. Then ask the user to type in either what color something in the picture is, or what the object itself is.
All in all, every solution is going to have its advantages and disadvantages. You are going to have to find a happy median between too hard for users to pass the antispam mechanism and the number of spam bots that can get through.
Robots cannot execute JavaScript so you do something like injecting some kind of hidden element into the page with JavaScript and then detecting it's presence prior to form submission but beware because some of your users will also have JavaScript disabled
Otherwise I think you will be forced to use a form of client proof of "humanness"
The best solution I've found to avoid getting spammed by bots is using a very trivial question or field on your form.
Try adding a field like these :
- Copy "hello" in the box aside
- 1+1 = ?
- Copy the website name in the box
These tricks require the user to understant what must be input on the form, thus making it much harder to be the target of massive bot form-filling.
EDIT
The backside of this method, as you stated in your question, is the extra step for the user to validate its form. But, in my opinion, it is far simpler than a captcha and the overhead when filling the form is not more than 5 seconds, which seems acceptable from the user point of view.
There is a tutorial about this on the JQuery site. Although it's JQuery the idea is framework independent.
If JavaScript isn't available then you may need to fall back to CAPTCHA type approach.
the easy way i found to do this is to put a field with a value and ask the user to remove the text in this field. since bots only fill them up. if the field is not empty it means that the user is not human and it wont be posted. its the same purpose of a captcha code.
Its just an idea, id used that in my application and works well
you can create a cookie on mouse movement with javascript or jquery and in server side check if cookie exist, because only humans have mouse, cookie can be created only by them the cookie can be a timestamp or a token that can be validate
Use 1) form with tokens 2) Check form to form delay with IP address 3) Block IP (optional)
In my experience, if the form is just a "contact" form you don't need special measures. Spam get decently filtered by webmail services (you can track webform requests via server-scripts to see what effectively reach your email, of course I assume you have a good webmail service :D)
Btw I'm trying not to rely on sessions for this (like, counting how many times a button is clicked to prevent overloads).
I don't think that's good, Indeed what I want to achieve is receiving emails from users that do some particular action because those are the users I'm interested in (for example users that looked at "CV" page and used the proper contact form). So if the user do something I want, I start tracking its session and set a cookie (I always set session cookie, but when I don't start a session it is just a fake cookie made to believe the user has a session). If the user do something unwanted I don't bother keeping a session for him so no overload etc.
Also It would be nice for me that advertising services offer some kind of api(maybe that already exists) to see if the user "looked at the ad", it is likely that users looking at ads are real users, but if they are not real well at least you get 1 view anyway so nothing loss. (and trust me, ads controls are more sophisticated than anything you can do alone)
Actually the trap with display: none works like a charm. It helps to move the CSS declaration to a file containing any global style sheets, which would force spam bots to load those as well (a direct style="display:none;" declaration could likely be interpreted by a spam bot, as could a local style declaration within the document itself).
This combined with other countermeasures should make it moot for any spam bots to unload their junk (I have a guest book secured with a variety of measures, and so far they have fallen for my primary traps - however, should any bot bypass those, there are others ready to trigger).
What I'm using is a combination of fake form fields (also described as invalid fields in case a browser is used that doesn't handle CSS in general or display: none in particular), sanity checks (i. e. is the format of the input valid?), time stamping (both too fast and too slow submissions), MySQL (for implementing blacklists based on e-mail and IP addresses as well as flood filters), DNSBLs (e. g. the SBL+XBL from Spamhaus), text analysis (e. g. words that are a strong indication for spam) and verification e-mails (to determine whether or not the e-mail address provided is valid).
One note on verification mails: This step is entirely optional, but when one chooses to implement it, this process must be as easy-to-use as possible (that is, it should boil down to clicking a link contained in the e-mail) and cause the e-mail address in question to be whitelisted for a certain period of time so that subsequent verifications are avoided in case that user wants to make additional posts.
I use a method where there is a hidden textbox. Since bots parse the website they probably fill it. Then I check it if it is empty if it is not website returns back.
Add email verification. The user receives an email and he needs to click a link. Otherwise discard the post in some time.
I've added a time check to my forms. The forms will not be submitted if filled in less than 3 seconds and this was working great for me especially for the long forms. Here's the form check function that I call on the submit button
function formCheck(){
var timeStart;
var timediff;
$("input").bind('click keyup', function () {
timeStart = new Date().getTime();
});
timediff= Math.round((new Date().getTime() - timeStart)/1000);
if(timediff < 3) {
//throw a warning or don't submit the form
}
else submit(); // some submit function
}
You can try to cheat spam-robots adding the correct action atribute after Javascript validation. so if the robot block javascript they never submit correctly the form.
HTML
<form id="form01" action="false-action.php">
//your inputs
<button>SUBMIT</button>
</form>
JAVASCRIPT
$('#form01 button').click(function(){
//your Validations and if everything is ok:
$('#form01').attr('action', 'correct-action.php').on("load",function(){
document.getElementById('form01').submit()
});
})
I add a "callback" after .attr() to prevent errors
With increasingly sophisticated spam bots and techniques like automated browsers, it will become harder to determine the source of spam. But whether posted by software, a human, or both, spam is spam because of its content. I think the best solution is to run the posted content through an anti-spam API like Cleantalk or Akismet. It's relatively cheap and effective and doesn't hassle the user. You can check form submission times and the other traditional checks for less sophisticated bots before hitting the API.
Just my five cents worth. If the object of this is to stop 99% of robots which sounds pretty good, and if 99% of robots can't run Java-script the best solution that beats all is simply to not use a form that has an action of submit with a post URL.
If the form is controlled via java-script and the java-script collects the form data and then sends it via a HTTP request, no robot can submit the form. Since the submit button would use Java-script to run the code that sends the form.
'Programming' 카테고리의 다른 글
공백이있는 왼쪽 패드 printf (0) | 2020.08.18 |
---|---|
다차원 배열을 텍스트 파일에 쓰는 방법은 무엇입니까? (0) | 2020.08.18 |
Rails 용 라우팅 리소스에서 : id 매개 변수의 이름을 변경합니다. (0) | 2020.08.18 |
Electron 앱에서 console.log () 사용 (0) | 2020.08.18 |
PHP를 사용하여 파일을 보낼 때 다운로드가 재개됩니까? (0) | 2020.08.18 |