Skip to content

Commit acc01ad

Browse files
committed
Merge branch 'develop'
2 parents 394791e + 6880f8e commit acc01ad

File tree

6 files changed

+32
-11
lines changed

6 files changed

+32
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Custom
22
acstis/.semver
33
ghostdriver.log
4+
extended_test.py
45

56
# OS
67
Thumbs.db

.semver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.1
1+
3.0.2

acstis/Driver.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from nyawc.CrawlerActions import CrawlerActions
3434
from nyawc.http.Request import Request
3535
from nyawc.http.Response import Response
36+
from nyawc.helpers.HTTPRequestHelper import HTTPRequestHelper
3637
from acstis.helpers.BrowserHelper import BrowserHelper
3738
from acstis.helpers.PackageHelper import PackageHelper
3839
from acstis.Scanner import Scanner
@@ -90,9 +91,12 @@ def __signal_handler(self, signum, frame):
9091

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

93-
def __set_angular_version(self):
94+
def __set_angular_version(self, startpoint):
9495
"""Find and set the AngularJS version as class attribute
9596
97+
Args:
98+
startpoint (:class:`nyawc.http.Request`): The startpoint request.
99+
96100
Returns:
97101
str: True if found and set, False otherwise.
98102
@@ -107,7 +111,7 @@ def __set_angular_version(self):
107111
colorlog.getLogger().info("Waiting until DOM is completely loaded.")
108112

109113
self.__angular_version = BrowserHelper.javascript(
110-
QueueItem(Request(self.__args.domain), Response(self.__args.domain)),
114+
QueueItem(startpoint, Response(self.__args.domain)),
111115
"return angular.version.full"
112116
)
113117

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

125-
if self.__set_angular_version():
129+
startpoint = Request(self.__args.domain)
130+
HTTPRequestHelper.patch_with_options(startpoint, self.__options)
131+
132+
if self.__set_angular_version(startpoint):
126133
crawler = Crawler(self.__options)
127134
signal.signal(signal.SIGINT, self.__signal_handler)
128135

129-
startpoint = Request(self.__args.domain)
130136
crawler.start_with(startpoint)
131137

132138
# Exit the process with the correct status code

acstis/helpers/BrowserHelper.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
import stat
2929
import ctypes
3030
import colorlog
31+
import requests
3132
import requests.cookies
3233

3334
from selenium import webdriver
3435
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
36+
from nyawc.helpers.HTTPRequestHelper import HTTPRequestHelper
3537
from nyawc.helpers.URLHelper import URLHelper
3638
from nyawc.http.Request import Request
3739

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

117119
if queue_item:
118120

119-
# Authentication
121+
# Add authentication header to request
120122
if queue_item.request.auth:
121123
queue_item.request.auth(queue_item.request)
122124

123-
# Headers
125+
# Add cookie header to request
126+
if queue_item.request.cookies:
127+
cookie_string = HTTPRequestHelper.get_cookie_header(queue_item)
128+
queue_item.request.headers["Cookie"] = cookie_string
129+
130+
# Add headers to PhantomJS
124131
if queue_item.request.headers:
132+
default_headers = requests.utils.default_headers()
125133
for (key, value) in queue_item.request.headers.items():
126134
if key.lower() == "user-agent":
127135
capabilities["phantomjs.page.settings.userAgent"] = value
128136
else:
129-
capabilities["phantomjs.page.settings." + key] = value
137+
138+
# PhantomJS has issues with executing JavaScript on pages with GZIP encoding.
139+
# See link for more information (https://github.com/detro/ghostdriver/issues/489).
140+
if key == "Accept-Encoding" and "gzip" in value:
141+
continue
142+
143+
capabilities["phantomjs.page.customHeaders." + key] = value
130144

131145
# Proxies
132146
if queue_item.request.proxies:
133147
service.extend(BrowserHelper.__proxies_to_service_args(queue_item.request.proxies))
134148

135-
driver = BrowserHelper.__get_phantomjs_driver()
149+
driver_path = BrowserHelper.__get_phantomjs_driver()
136150
return webdriver.PhantomJS(
137-
executable_path=driver,
151+
executable_path=driver_path,
138152
desired_capabilities=capabilities,
139153
service_args=service
140154
)

acstis/phantomjs/mac-2.1.1

100644100755
File mode changed.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
colorlog==2.10.0
2-
nyawc==1.7.8
2+
nyawc==1.7.10
33
requests==2.18.1
44
requests_toolbelt==0.8.0
55
selenium==3.4.3

0 commit comments

Comments
 (0)