• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • About Darknet
  • Hacking Tools
  • Popular Posts
  • Darknet Archives
  • Contact Darknet
    • Advertise
    • Submit a Tool
Darknet – Hacking Tools, Hacker News & Cyber Security

Darknet - Hacking Tools, Hacker News & Cyber Security

Darknet is your best source for the latest hacking tools, hacker news, cyber security best practices, ethical hacking & pen-testing.

Link & Comment Spamming – A possible solution.

August 29, 2006

Views: 12,431

[ad]

Recently one of the sites I am developing for my self was link spammed. Some unpleasant individual decided that it would be fun to post 160 ‘comments’ spread over all the blog posts. All the comments contained was URL’s. Even more stupid they used BB tags, but as I wrote the site it doesn’t use them.

Any way, obviously this isn’t some thing I want, so I deleted them all with a quick bit of SQL. No one else has posted a comment to the site because like I said, its still under development.

However, it happened once so there is no reason to think it wont happen again. I thought about the problem for a while, and the only solution is to incorporate some kind of humanity check. Because lets face it, its not like some one sat there and entered them all in. Its was some kind of bot.

Now, I don’t really like the ones that ask you to type the letters from some hard to read image. I can do that, no problem but they look ugly, and if the user was colour blind, or any other sight related issue, then you buggered.

So, I have come up with a different solution. The idea is to ask a random question, some thing that’s so easy any every one will know the answer, but unless you can read, you wont know what the answer is.

While I was busy implementing this solution, and believe me it didn’t take very long, another 20 comments of a very similar nature where posted. How annoying is that?

The solution seems to work for now. There have been no more comments since I completed the changes, but then maybe its only time until the bot gets adjusted, time will tell. But I thought other might benefit from having it so here goes, how to add random questions to your site.

Oh, one thing, I am not going to list my questions here, for a start it took me a shockingly long time to think of 30 really really easy questions, and I also don’t want to give a list of the question text and answers away.

So – on with the show. First off you will need 2 tables, one for the questions and one to keep track of what questions you have asked each user.

The questions table is easy, 3 coloums. Question_id, question and answer. The question id is just a unique number, the question and answer are both varchar.

1
2
3
4
5
6
CREATE TABLE `capture_questions` (
  `question_id` bigint(20) unsigned NOT NULL auto_increment,
  `question` varchar(255) NOT NULL default '',
  `answer` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`question_id`)
) ;

Then we have the table used to store the asked questions. This is even less complicated. All you need is 2 fields, one for the question that was asked ID, and one to store the users Session ID.

1
2
3
4
CREATE TABLE `capture_question_asked` (
  `sid` varchar(60) NOT NULL default '0',
  `qid` bigint(20) unsigned NOT NULL default '0'
);

So far, that’s all easy enough. You fill in the question table with as many questions as you can think of, along the lines of “is the sky blue” with an answer of “yes” or perhaps “What is 25 + 30” answer, obviously “55”.

Of course you can create the tables and this isn’t going to do a hell of a lot. So, you’ll need a class to deal with it all. This is a copy of the code, though you will notice the use of the functions “performQuery” and “fetchRow”, these are from my own DB layer. They replace the standard MySQL commands by using a wrapper. It makes it easy to port code from one RDBMS to the other. I personally like this solution because its light weight and simple. But it’s a bit beyond the scope of this post.

So, the class? Its got 2 methods: getQuestion and getAnswer. They both take the a single parameter of ‘sid’. This is the session id, but for compatibility it is passed in to the function so it can basically be any thing.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class captureClass extends baseClass {
  function getQuestion($sid) {
    $question = false ;
 
    $deleteSQL = "DELETE FROM capture_question_asked " ;
    $deleteSQL .= " WHERE sid = '$sid' " ;
 
    performQuery($deleteSQL) ;
 
    $selectQuestionSQL = "SELECT question_id, question " ;
    $selectQuestionSQL .= "FROM capture_questions " ;
    $selectQuestionSQL .= "ORDER BY rand(NOW()) LIMIT 0 , 1 " ;
 
    $selectQuestionQuery = performQuery($selectQuestionSQL) ;
 
    if ($selectQuestionQuery) {
      if ($row=fetchRow($selectQuestionQuery)) {
        $question = $row['question'] ;
        $qid = $row['question_id'] ;
 
        $insertSQL = "INSERT INTO capture_question_asked (sid, qid) " ;
        $insertSQL .= "VALUES ('$sid', '$qid') " ;
        performQuery($insertSQL) ;
      }
    }
 
    return $question ;
  }
 
  function getAnswer($sid) {
    $answer = '' ;
 
    $selectQuestionIdSQL = "SELECT qid FROM capture_question_asked " ;
    $selectQuestionIdSQL .= "WHERE sid = '$sid' " ;
 
    $selectQuestionIdQuery = performQuery($selectQuestionIdSQL) ;
 
    if ($selectQuestionIdQuery) {
      if ($row=fetchRow($selectQuestionIdQuery)) {
        $qid = $row['qid'] ;
        $selectAnswerSQL = "SELECT answer FROM capture_questions " ;
        $selectAnswerSQL .= " WHERE question_id = '$qid' " ;
 
        $selectAnswerQuery = performQuery($selectAnswerSQL) ;
 
        if ($selectAnswerQuery) {
          if ($answerRow=fetchRow($selectAnswerQuery)) {
            $answer = $answerRow['answer'] ;
          }
        }
      }
    }
 
    return $answer ;
  }
}

How do you use it? Well, when your page displays the form you make a call to getQuestion and display it. For a while I thought about putting the question ID into the page, but only for a couple of seconds as I realised any half decent attempt to beat the system would just replace the ID with one with a known answer, infact as I suspect that the form is not used, simple data “posted” to the page, then it wouldn’t even matter.

That’s why we keep that information in the database.

Any way, once the form is submitted you then ask the class to get the answer for the current session, and compare what the user entered to the correct answer. I’d suggest forcing lower case, or upper case if you want, but basically make the comparison case insensitive.

If the answers don’t match then the person is, well an idiot or a bot. If no answer is available, then some ones messed with the session, or never even used the form. Doesn’t matter which, either way its an error.

I don’t think I will bother to explain the code it self, its really not that complicated. I think maybe the only bit that might seem a bit strange is the sql used to select a question:

1
2
  SELECT question_id, question FROM capture_questions
  ORDER BY rand(NOW()) LIMIT 0 , 1

This simply selects a random record from the table, because its ordered by “rand”. This basically means that for each record in the table a random number is generated, and then the records are ordered by the value. Because we only want one question we use the limit to only select the first record, how ever because each time the records are selected they will be in a different order, each time you get a different record cool ha? :-)

I hope this proves to work over time. I’ll have to keep any eye on it. Just to see how it goes. If any one can see any thing wrong with it, well, let me know.

Digg This Article

Share
Tweet
Share
Buffer
WhatsApp
Email
0 Shares

Filed Under: Hacking News, Spammers & Scammers, Web Hacking Tagged With: CAPTCHA



Reader Interactions

Comments

  1. blah says

    August 29, 2006 at 1:56 pm

    bllah

  2. Pedro Pinheiro says

    August 29, 2006 at 6:23 pm

    Two comments:
    1) If the questions are mainly of the yes/no type, a brute force attack will overcome the difficulty. And the “what is 20+5” and similar questions are subject to be answered by systems like google (try to type “what is 10 times 5” on google), which the boots could use;
    2) What happens exactly when you get it wrong? Does it give you immediately another chance to answer another question correctly? If so, it would also make it more vulnerable to brute force attacks.

    I personally like the system implemented on WordPress. You can set several parameters regarding the number of links in the comment, or if to allow only comments from users that have already had comments aproved before (identified through the e-mail given, no e-mail confirmation is sent).

  3. Nounours says

    August 29, 2006 at 7:09 pm

    You are not the only one to have this problem. I did not experiment by myself but it seems to work.
    The idea is to make people recognize pictures like kitten or others animals.

    http://www.thepcspy.com/articles/security/the_cutest_humantest_kittenauth

    Hope it can help you

    Good luck :p

  4. Missi says

    August 30, 2006 at 3:40 am

    Hi, i have an additional field in my weblog against commentspam and a rule in my htaccess against trackbackspam. This rule blocks the direct acess on wp-trackback.php.
    (RewriteRule ^wp-trackback\.php.*$ – [F,L]) It works perfect.

    (Sorry for my english, my german is much better. :o) )

  5. kevin says

    February 22, 2007 at 3:59 am

    Hi Missi, I use the same php code you use it works very well for me as well.

  6. missi says

    February 22, 2007 at 1:02 pm

    Kevin, additional rename the whole trackbackmachine. I post it here in german, here is a google-translate.

    This ist a simple fix and i´m 100% spamfree. :)

    (Btw. Haydies, i need to turn on Cookies for this challenge, this is bad. :\ )

Primary Sidebar

Search Darknet

  • Email
  • Facebook
  • LinkedIn
  • RSS
  • Twitter

Advertise on Darknet

Latest Posts

Falco - Real-Time Threat Detection for Linux and Containers

Falco – Real-Time Threat Detection for Linux and Containers

Views: 296

Security visibility inside containers, Kubernetes, and cloud workloads remains among the hardest … ...More about Falco – Real-Time Threat Detection for Linux and Containers

Wazuh – Open Source Security Platform for Threat Detection, Visibility & Compliance

Wazuh – Open Source Security Platform for Threat Detection, Visibility & Compliance

Views: 590

As threat surfaces grow and attack sophistication increases, many security teams face the same … ...More about Wazuh – Open Source Security Platform for Threat Detection, Visibility & Compliance

Best Open Source HIDS Tools for Linux in 2025 (Compared & Ranked)

Views: 555

With more businesses running Linux in production—whether in bare metal, VMs, or containers—the need … ...More about Best Open Source HIDS Tools for Linux in 2025 (Compared & Ranked)

SUDO_KILLER - Auditing Sudo Configurations for Privilege Escalation Paths

SUDO_KILLER – Auditing Sudo Configurations for Privilege Escalation Paths

Views: 593

sudo is a powerful utility in Unix-like systems that allows permitted users to execute commands with … ...More about SUDO_KILLER – Auditing Sudo Configurations for Privilege Escalation Paths

Bantam - Advanced PHP Backdoor Management Tool For Post Exploitation

Bantam – Advanced PHP Backdoor Management Tool For Post Exploitation

Views: 451

Bantam is a lightweight post-exploitation utility written in C# that includes advanced payload … ...More about Bantam – Advanced PHP Backdoor Management Tool For Post Exploitation

AI-Powered Cybercrime in 2025 - The Dark Web’s New Arms Race

AI-Powered Cybercrime in 2025 – The Dark Web’s New Arms Race

Views: 676

In 2025, the dark web isn't just a marketplace for illicit goods—it's a development lab. … ...More about AI-Powered Cybercrime in 2025 – The Dark Web’s New Arms Race

Topics

  • Advertorial (28)
  • Apple (46)
  • Countermeasures (228)
  • Cryptography (82)
  • Database Hacking (89)
  • Events/Cons (7)
  • Exploits/Vulnerabilities (431)
  • Forensics (65)
  • GenAI (3)
  • Hacker Culture (8)
  • Hacking News (229)
  • Hacking Tools (684)
  • Hardware Hacking (82)
  • Legal Issues (179)
  • Linux Hacking (74)
  • Malware (238)
  • Networking Hacking Tools (352)
  • Password Cracking Tools (104)
  • Phishing (41)
  • Privacy (219)
  • Secure Coding (118)
  • Security Software (235)
  • Site News (51)
    • Authors (6)
  • Social Engineering (37)
  • Spammers & Scammers (76)
  • Stupid E-mails (6)
  • Telecomms Hacking (6)
  • UNIX Hacking (6)
  • Virology (6)
  • Web Hacking (384)
  • Windows Hacking (169)
  • Wireless Hacking (45)

Security Blogs

  • Dancho Danchev
  • F-Secure Weblog
  • Google Online Security
  • Graham Cluley
  • Internet Storm Center
  • Krebs on Security
  • Schneier on Security
  • TaoSecurity
  • Troy Hunt

Security Links

  • Exploits Database
  • Linux Security
  • Register – Security
  • SANS
  • Sec Lists
  • US CERT

Footer

Most Viewed Posts

  • Brutus Password Cracker – Download brutus-aet2.zip AET2 (2,297,520)
  • Darknet – Hacking Tools, Hacker News & Cyber Security (2,173,103)
  • Top 15 Security Utilities & Download Hacking Tools (2,096,637)
  • 10 Best Security Live CD Distros (Pen-Test, Forensics & Recovery) (1,199,691)
  • Password List Download Best Word List – Most Common Passwords (933,521)
  • wwwhack 1.9 – wwwhack19.zip Web Hacking Software Free Download (776,170)
  • Hack Tools/Exploits (673,298)
  • Wep0ff – Wireless WEP Key Cracker Tool (530,182)

Search

Recent Posts

  • Falco – Real-Time Threat Detection for Linux and Containers May 19, 2025
  • Wazuh – Open Source Security Platform for Threat Detection, Visibility & Compliance May 16, 2025
  • Best Open Source HIDS Tools for Linux in 2025 (Compared & Ranked) May 14, 2025
  • SUDO_KILLER – Auditing Sudo Configurations for Privilege Escalation Paths May 12, 2025
  • Bantam – Advanced PHP Backdoor Management Tool For Post Exploitation May 9, 2025
  • AI-Powered Cybercrime in 2025 – The Dark Web’s New Arms Race May 7, 2025

Tags

apple botnets computer-security darknet Database Hacking ddos dos exploits fuzzing google hacking-networks hacking-websites hacking-windows hacking tool Information-Security information gathering Legal Issues malware microsoft network-security Network Hacking Password Cracking pen-testing penetration-testing Phishing Privacy Python scammers Security Security Software spam spammers sql-injection trojan trojans virus viruses vulnerabilities web-application-security web-security windows windows-security Windows Hacking worms XSS

Copyright © 1999–2025 Darknet All Rights Reserved · Privacy Policy