Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement a resource detector using Python

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to use Python to achieve a resource detector, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

First of all, introduce the relevant modules:

Requests, used to request the target site

Threading to enable multithreading

Sys, used to parse command line arguments

Getopt for handling command line arguments

Then, define a banner for a program:

This banner is used to show it when the program starts, and it is of little use except to make the program a little more personal.

Define another function to show the usage of the program:

Because our program runs on the command line, we need to set some parameters. Here, we use:

-w to specify the URL

-t to specify the number of threads

-f to specify the dictionary file

None of these three parameters is indispensable.

After these two functions are created, the running program will appear with the following interface:

Doesn't it look a little interesting.

Next, we create a class request_performer () that inherits from Thread, which is used to create a thread and make a request to the target site and get a response:

In the run () method of the request_performer () class, we use requests to request the URL and print out the status code of the response. And this is the main function of our detector.

Then create a function launcher_thread () that starts the request_performer () class, which is used to traverse the keywords in the dictionary file into URL and generate a new thread.

Continue to create a function start () that receives arguments from the command line and passes it to the launcher_thread () function:

Finally, of course, it runs in the main program:

What on earth is the use of our program?

Here, we have to mention the FUZZDB database mentioned above again. Fuzzdb is a database for fuzzy testing, similar to a huge dictionary. The contents of these dictionaries are all directories or paths maintained by security gods and found to be likely to be attack points in practice.

We can open a txt file in the database to see:

This is a dictionary for plug-ins in the wordpress blog system, which contains the paths and directories of plug-ins.

Test the violence detector.

Do you remember building the virtual machine environment introduced in that article in the penetration test environment? There is a full of vulnerabilities in the Web application http://www.scruffybank.com/, we can use the violence detector we just wrote to explore this site.

Let's start with a simple dictionary:

We run the command on the command line:

The results are obtained:

There are three successful responses in the common.txt dictionary. Let's open one of the http://www.scruffybank.com/robots.txt to see:

Contains three links that forbid search engines to crawl, literally, one of which is the background address admin, but on the results page we know that / admin is 404 error, but there is a / Admin, let's open it and have a look:

The authentication login box pops up, but we don't have a user name and password, so we can only give up for now.

Let's test it again with a dictionary in the FUZZDB database. Select PHP.fuzz.txt under the fuzzdb-master/discovery/predictable-filepaths/php directory:

Also run the command on the terminal command line:

The results are obtained:

Although there are many 404, we still found some successful responses.

For example, info.php, open the info interface that used to be PHP:

Login.php is the login page:

On how to use Python to achieve a resource detector to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report