In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to add screenshot function to Python penetration test detector". In daily operation, I believe many people have doubts about how to add screenshot function to Python penetration test detector. The editor consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for everyone to answer the question of "how to add screenshot function to Python penetration test detector". Next, please follow the editor to study!
An overview of this article
Selenium and PhantomJS
Add screenshot function to penetration test detector
Test new features
In the previous article, we wrote a penetration test detector using Python, obtained dictionary information from fuzz database, used requests module to request splicing assembled URL, thus obtained the response content of URL, and printed the sorted information with the help of termcolor module.
Now we have another immature idea, and we don't know whether to say it or not.
In a normal Web penetration test, after we explore a website and get all the results, we must see what the page that requests a successful link looks like. If there are too many URL, it would be a waste of time to click one by one. So we need to get a screenshot of the web page so that we can view the web page after probing.
Selenium and PhantomJS
There is probably nothing requests can do to take a screenshot of the requested web page. At this point, we need to use another tool-Selenium, a module dedicated to Web automation testing.
It can realize all kinds of actions of the browser with the help of the browser kernel driver. In Python, we can easily install through pip:
Selenium can use a variety of browser kernels, such as mainstream Chrome, Firefox, etc., but here we use another non-mainstream browser-PhantomJS, a headless browser. In addition to no graphical interface, it has all the functions of other major browsers.
We can use phantomjs on the command line, or we can use Selenium in Python to call phantomjs:
In this way, a browser kernel that uses PhantomJS as a Selenium call is implemented.
After instantiating a webdriver, you can access a URL using the get () method:
Using the save_screenshot () method, you can save a screenshot of the page.
For other uses of Selenium, you can see other blog articles or materials on the Internet. Here, we mainly use these two methods.
Add a screenshot of a web page
Once we know how to use Selenium for web requests and screenshots, we can add new features to our penetration test detector.
Of course, not every page needs to save a screenshot of the page. We take a screenshot of the page with a successful request, that is, only the page with a status code greater than or equal to 200 and less than 300 needs a screenshot.
Let's modify the run () method in the request_performer () class:
We mainly added four lines of code:
Instantiate a webdriver, request a url, wait 3 seconds, set the browser window size, and save a screenshot of the web page.
Test the function of web screenshot
After modifying the code, we can test our version 4 penetration test detector.
Run the command on the command line terminal:
After running, let's take a look at our folder:
There are five more pictures, let's open one to see:
It's the same as what the browser opens:
In this way, the penetration test detector written by Python is basically perfect.
Next, we will introduce password attacks for Python Web penetration testing!
At this point, the study on "how to add screenshot function to Python penetration test detector" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.