Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tijme committed Oct 28, 2017
2 parents 394791e + 6880f8e commit acc01ad
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Custom
acstis/.semver
ghostdriver.log
extended_test.py

# OS
Thumbs.db
Expand Down
2 changes: 1 addition & 1 deletion .semver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.1
3.0.2
14 changes: 10 additions & 4 deletions acstis/Driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from nyawc.CrawlerActions import CrawlerActions
from nyawc.http.Request import Request
from nyawc.http.Response import Response
from nyawc.helpers.HTTPRequestHelper import HTTPRequestHelper
from acstis.helpers.BrowserHelper import BrowserHelper
from acstis.helpers.PackageHelper import PackageHelper
from acstis.Scanner import Scanner
Expand Down Expand Up @@ -90,9 +91,12 @@ def __signal_handler(self, signum, frame):

colorlog.getLogger().warning("Received SIGINT, stopping the crawling threads safely. This could take up to 30 seconds (the thread timeout).")

def __set_angular_version(self):
def __set_angular_version(self, startpoint):
"""Find and set the AngularJS version as class attribute
Args:
startpoint (:class:`nyawc.http.Request`): The startpoint request.
Returns:
str: True if found and set, False otherwise.
Expand All @@ -107,7 +111,7 @@ def __set_angular_version(self):
colorlog.getLogger().info("Waiting until DOM is completely loaded.")

self.__angular_version = BrowserHelper.javascript(
QueueItem(Request(self.__args.domain), Response(self.__args.domain)),
QueueItem(startpoint, Response(self.__args.domain)),
"return angular.version.full"
)

Expand All @@ -122,11 +126,13 @@ def __set_angular_version(self):
def start(self):
"""Start the crawler."""

if self.__set_angular_version():
startpoint = Request(self.__args.domain)
HTTPRequestHelper.patch_with_options(startpoint, self.__options)

if self.__set_angular_version(startpoint):
crawler = Crawler(self.__options)
signal.signal(signal.SIGINT, self.__signal_handler)

startpoint = Request(self.__args.domain)
crawler.start_with(startpoint)

# Exit the process with the correct status code
Expand Down
24 changes: 19 additions & 5 deletions acstis/helpers/BrowserHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
import stat
import ctypes
import colorlog
import requests
import requests.cookies

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from nyawc.helpers.HTTPRequestHelper import HTTPRequestHelper
from nyawc.helpers.URLHelper import URLHelper
from nyawc.http.Request import Request

Expand Down Expand Up @@ -116,25 +118,37 @@ def __get_browser(queue_item=None):

if queue_item:

# Authentication
# Add authentication header to request
if queue_item.request.auth:
queue_item.request.auth(queue_item.request)

# Headers
# Add cookie header to request
if queue_item.request.cookies:
cookie_string = HTTPRequestHelper.get_cookie_header(queue_item)
queue_item.request.headers["Cookie"] = cookie_string

# Add headers to PhantomJS
if queue_item.request.headers:
default_headers = requests.utils.default_headers()
for (key, value) in queue_item.request.headers.items():
if key.lower() == "user-agent":
capabilities["phantomjs.page.settings.userAgent"] = value
else:
capabilities["phantomjs.page.settings." + key] = value

# PhantomJS has issues with executing JavaScript on pages with GZIP encoding.
# See link for more information (/~https://github.com/detro/ghostdriver/issues/489).
if key == "Accept-Encoding" and "gzip" in value:
continue

capabilities["phantomjs.page.customHeaders." + key] = value

# Proxies
if queue_item.request.proxies:
service.extend(BrowserHelper.__proxies_to_service_args(queue_item.request.proxies))

driver = BrowserHelper.__get_phantomjs_driver()
driver_path = BrowserHelper.__get_phantomjs_driver()
return webdriver.PhantomJS(
executable_path=driver,
executable_path=driver_path,
desired_capabilities=capabilities,
service_args=service
)
Expand Down
Empty file modified acstis/phantomjs/mac-2.1.1
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
colorlog==2.10.0
nyawc==1.7.8
nyawc==1.7.10
requests==2.18.1
requests_toolbelt==0.8.0
selenium==3.4.3

0 comments on commit acc01ad

Please sign in to comment.