Skip to content

Commit a80d041

Browse files
author
micabot
committed
Merge branch 'white/master'
2 parents c305b5b + d794967 commit a80d041

76 files changed

Lines changed: 6290 additions & 387 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

RELEASE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ Please run ./faraday.py --update
1010
New features in the latest update
1111
=====================================
1212

13+
TBA:
14+
---
15+
* Continuous Scanning Tool cscan added to ./scripts/cscan
16+
* Fix for saving objects without parent
17+
* Hosts and Services views now have pagination and search
18+
* Updates version number on Faraday Start
19+
* Visual fixes on Firefox
20+
* Migrate graphs from D3.js to Chart.js
21+
* Added Services columns to Status Report
22+
* Added sections of Commercial versions
23+
* Converted references to links in Status Report. Support for CVE, CWE, Exploit Database and Open Source Vulnerability Database
24+
* Added Pippingtom, SSHdefaultscan and pasteAnalyzer plugins
25+
* Fixed Debian install
26+
1327
Sep 10, 2015:
1428
---
1529
* Adding filename path information of report imported in history command

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.14
1+
1.0.15

config/default.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<faraday>
33

44
<appname>Faraday - Penetration Test IDE</appname>
5-
<version>1.0.14</version>
5+
<version>1.0.15</version>
66
<debug_status>0</debug_status>
77
<font>-Misc-Fixed-medium-r-normal-*-12-100-100-100-c-70-iso8859-1</font>
88
<home_path>~/</home_path>

config/globals.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
'''
77

88
CONST_REQUIREMENTS_FILE = 'requirements.txt'
9+
CONST_CONFIG = 'views/reports/_attachments/scripts/config/config.json'
910
CONST_FARADAY_HOME_PATH = '~/.faraday'
1011
CONST_FARADAY_PLUGINS_PATH = 'plugins'
1112
CONST_FARADAY_PLUGINS_REPO_PATH = 'plugins/repo'

faraday.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
import platform
1919
import subprocess
2020
import pip
21+
import json
2122

2223
from utils.logs import getLogger, setUpLogger
2324
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/external_libs/lib/python2.7/dist-packages')
2425
from config.configuration import getInstanceConfiguration
2526
from config.globals import *
2627
from utils.profilehooks import profile
28+
from utils.user_input import query_yes_no
2729

2830

2931

@@ -540,6 +542,29 @@ def checkCouchUrl():
540542
# Non fatal error
541543
pass
542544

545+
def checkVersion():
546+
try:
547+
f = open(CONST_VERSION_FILE)
548+
f_version = f.read().strip()
549+
if not args.update:
550+
if getInstanceConfiguration().getVersion() != None and getInstanceConfiguration().getVersion() != f_version:
551+
logger.warning("You have different version of Faraday since your last run.\nRun ./faraday.py --update to update configuration!")
552+
if query_yes_no('Do you want to close Faraday?', 'yes'):
553+
exit(-1)
554+
555+
getInstanceConfiguration().setVersion(f_version)
556+
f.close()
557+
558+
doc = {"ver": getInstanceConfiguration().getVersion()}
559+
560+
if os.path.isfile(CONST_CONFIG):
561+
os.remove(CONST_CONFIG)
562+
with open(CONST_CONFIG, "w") as doc_file:
563+
json.dump(doc, doc_file)
564+
except Exception as e:
565+
getLogger("launcher").error("It seems that something's wrong with your version\nPlease contact customer support")
566+
exit(-1)
567+
543568

544569
def init():
545570
"""Initializes what is needed before starting.
@@ -570,6 +595,7 @@ def main():
570595
checkConfiguration()
571596
setConf()
572597
checkCouchUrl()
598+
checkVersion()
573599
setUpLogger()
574600
update()
575601
checkUpdates()

cleanXML.py renamed to helpers/cleanXML.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
See the file 'doc/LICENSE' for the license information
66
77
'''
8+
'''
9+
This script fixes invalid XMLs.
10+
'''
11+
812
import argparse
913
from bs4 import BeautifulSoup
1014

helpers/fixBrokenChildren.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/usr/bin/env python2.7
2+
'''
3+
Faraday Penetration Test IDE
4+
Copyright (C) 2014 Infobyte LLC (http://www.infobytesec.com/)
5+
See the file 'doc/LICENSE' for the license information
6+
7+
'''
8+
'''
9+
This script either updates or removes Interfaces, Services and Vulnerabilities in case their parent property is null.
10+
If the property is null but a parent is found in Couch, the document is updated.
11+
If the parent is not found in Couch the document is deleted, since it is an invalid one.
12+
'''
13+
14+
import argparse
15+
import json
16+
import requests
17+
import os
18+
from pprint import pprint
19+
20+
def main():
21+
#arguments parser
22+
parser = argparse.ArgumentParser(prog='fixBrokenChildren', epilog="Example: ./%(prog)s.py")
23+
parser.add_argument('-c', '--couchdburi', action='store', type=str,
24+
dest='couchdb',default="http://127.0.0.1:5984",
25+
help='Couchdb URL (default http://127.0.0.1:5984)')
26+
parser.add_argument('-d', '--db', action='store', type=str,
27+
dest='db', help='DB to process')
28+
29+
#arguments put in variables
30+
args = parser.parse_args()
31+
dbs = list()
32+
33+
#default value from ENV COUCHDB
34+
couchdb = os.environ.get('COUCHDB')
35+
#Else from argument
36+
if not couchdb:
37+
couchdb = args.couchdb
38+
39+
if args.db:
40+
dbs.append(args.db)
41+
42+
if len(dbs) == 0:
43+
dbs = requests.get(couchdb + '/_all_dbs')
44+
dbs = dbs.json()
45+
dbs = filter(lambda x: not x.startswith('_') and x != 'cwe' and x != 'reports', dbs)
46+
47+
for db in dbs:
48+
fixDb(couchdb, db)
49+
50+
def fixDb(couchdb, db):
51+
couchdb = str(couchdb)
52+
db = str(db)
53+
54+
#get all broken elements from CouchDB
55+
headers = {'Content-Type': 'application/json'}
56+
payload = { "map" : """function(doc) { if(doc.type == \"Interface\" ||
57+
doc.type == \"Service\" ||
58+
doc.type == \"Vulnerability\" ||
59+
doc.type == \"VulnerabilityWeb\"){ if(doc.parent == null) emit(doc.parent, 1); }}""" }
60+
61+
r = requests.post(couchdb + '/' + db + '/_temp_view', headers=headers, data=json.dumps(payload))
62+
response_code = r.status_code
63+
64+
if response_code == 200:
65+
response = r.json()
66+
rows = response['rows']
67+
rows = sorted(rows, key=lambda x: x['id'])
68+
69+
if len(rows) > 0:
70+
print " [*[ Processing " + str(len(rows)) + " documents for " + db + " ]*]"
71+
72+
for row in rows:
73+
id = str(row['id'])
74+
parent = str(id[:id.rfind('.')])
75+
76+
parent_response = requests.get(couchdb + '/' + db + '/' + parent)
77+
parent_code = parent_response.status_code
78+
79+
child_response = requests.get(couchdb + '/' + db + '/' + id)
80+
child = child_response.json()
81+
82+
#object parent exists in Couch
83+
#update parent field in obj
84+
if parent_code == 200:
85+
print " - Updating " + child['type'] + " \"" + child['name'] + "\" with ID " + id
86+
child['parent'] = parent
87+
#print doc['parent']
88+
update = requests.put(couchdb + '/' + db + '/' + id, headers=headers, data=json.dumps(child))
89+
print " -- " + update.reason + " (" + str(update.status_code) + ")"
90+
91+
#object has no valid parent
92+
#delete obj
93+
elif parent_code == 404:
94+
# delete vuln
95+
print " - Deleting " + child['type'] + " \"" + child['name'] + "\" with ID " + id
96+
delete = requests.delete(couchdb + '/' + db + '/' + id + '?rev=' + child['_rev'])
97+
print " -- " + delete.reason + " (" + str(delete.status_code) + ")"
98+
elif parent_code == 401:
99+
print " Autorization required, make sure to add user:pwd to Couch URI using --couchdburi"
100+
else:
101+
print " Fail"
102+
else:
103+
print "Congratz, " + db + " is just fine!"
104+
elif response_code == 401:
105+
print " Autorization required to access " + db + ", make sure to add user:pwd to Couch URI using --couchdburi"
106+
107+
if __name__ == "__main__":
108+
main()

pushCwe.py renamed to helpers/pushCwe.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
Copyright (C) 2014 Infobyte LLC (http://www.infobytesec.com/)
55
See the file 'doc/LICENSE' for the license information
66
7+
'''
8+
'''
9+
This script upload a Vulnerability database to Couch.
10+
It takes the content of the DB from data/cwe.csv
711
'''
812
import argparse
913
import os
@@ -42,4 +46,4 @@ def main():
4246
workspace.save_doc(cwe_doc)
4347

4448
if __name__ == "__main__":
45-
main()
49+
main()

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ elif [[ "$os" =~ "Ubuntu 14.04".*|"Ubuntu 14.10".*|"Ubuntu Vivid Vervet (develop
6666
# Bug: https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1306991
6767
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
6868
python get-pip.py
69-
elif [[ "$os" =~ "Debian 7".*|"Debian 8".* ]]; then
69+
elif [[ "$os" =~ "Debian 7".*|"Debian 8".*|"stretch/sid".* ]]; then
7070
version="ubuntu13-10-$arch"
7171
down=1
7272
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py

model/controller.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def __add(self, obj, parent_id=None, *args):
448448
old_obj = dataMapper.find(obj.getID())
449449
if old_obj:
450450
if not old_obj.needs_merge(obj):
451-
#the object is exactly the same,
451+
# the object is exactly the same,
452452
# so return and do nothing
453453
return True
454454
if not self.addUpdate(old_obj, obj):
@@ -459,6 +459,20 @@ def __add(self, obj, parent_id=None, *args):
459459
object_parent = self.mappers_manager.find(parent_id)
460460
if object_parent:
461461
object_parent.addChild(obj)
462+
# we have to make sure that certain objects have to have a parent
463+
if (obj.class_signature in
464+
[model.hosts.Interface.class_signature,
465+
model.hosts.Service.class_signature,
466+
model.common.ModelObjectNote.class_signature,
467+
model.common.ModelObjectVuln.class_signature,
468+
model.common.ModelObjectVulnWeb.class_signature,
469+
model.common.ModelObjectCred.class_signature] and object_parent is None):
470+
# TODO: refactor log module. We need to log twice to see it in
471+
# qt and in the terminal. Ugly.
472+
msg = "A parent is needed for %s objects" % obj.class_signature
473+
getLogger(self).error(msg)
474+
model.api.log(msg)
475+
return False
462476
dataMapper.save(obj)
463477
self.treeWordsTries.addWord(obj.getName())
464478
if obj.class_signature == model.hosts.Host.class_signature:
@@ -879,7 +893,7 @@ def getAllHosts(self):
879893
hosts = self.mappers_manager.getMapper(
880894
model.hosts.Host.__name__).getAll()
881895
return hosts
882-
896+
883897
def getWebVulns(self):
884898
return self.mappers_manager.getMapper(
885899
model.common.ModelObjectVulnWeb.class_signature).getAll()

0 commit comments

Comments
 (0)