Skip to content

Commit

Permalink
Merge pull request #272 from aabilio/master
Browse files Browse the repository at this point in the history
Fix issue #271 and #273
  • Loading branch information
i3visio committed Jul 5, 2017
2 parents 97ea467 + 8b9a732 commit 31f7813
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ fuzz.txt
*.mtz
*.zip
*.back
osrframework-virtualenv
38 changes: 34 additions & 4 deletions osrframework/searchfy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,31 @@
import argparse
import json
import os
from multiprocessing import Process, Pipe

import osrframework.utils.banner as banner
import osrframework.utils.platform_selection as platform_selection
import osrframework.utils.configuration as configuration
import osrframework.utils.general as general

def getPlatformInfo(platform, query, process, mode, pipeConnection):
'''
Method to to get the info from the platform in a separete thread.
This is a fix to 'catch' segmentation faults from external platform libraries.
:param platform: <Platform> objects
:param queries: a query to be performed.
:param process: Whether to process all the profiles... SLOW!
:param mode: a string that represents a operation mode
:param pipeConnection: a pipe connection to send messages back to parent process
:return:
'''
# This returns a json.txt!
entities = platform.getInfo(query, process, mode)
pipeConnection.send(entities)
pipeConnection.close()

def performSearch(platformNames=[], queries=[], process=False, excludePlatformNames=[]):
'''
Method to perform the phone list.
Expand All @@ -58,10 +77,21 @@ def performSearch(platformNames=[], queries=[], process=False, excludePlatformNa
results = []
for q in queries:
for pla in platforms:
# This returns a json.txt!
entities = pla.getInfo(query=q, process = process, mode="searchfy")
if entities != "[]":
results += json.loads(entities)
# Getting the pipe connection
parent_conn, child_conn = Pipe()
# Starting a new process
p = Process(target=getPlatformInfo, args=(pla, q, process, "searchfy", child_conn))
p.start()
p.join()
# Look at the exit code to check if the process ended unexpectedly
if p.exitcode == -11:
print "WARNING. Something happened when trying to get info from: " + str(pla)
print "\n\n"
continue
# Getting the entities from the message sent by child process
entitites = parent_conn.recv()
results += json.loads(entitites)

return results

def main(args):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@
cmd = "copy \"" + fileToMove + "\" \"" + destiny + "\""
elif sys.platform == 'linux2' or sys.platform == 'darwin':
if not os.geteuid() == 0:
cmd = "cp \"" + fileToMove + "\" \"" + destiny + "\" -r"
cmd = "cp -r -- \"" + fileToMove + "\" \"" + destiny + "\""
else:
cmd = "sudo cp \"" + fileToMove + "\" \"" + destiny + "\" -r"
cmd = "sudo cp -r -- \"" + fileToMove + "\" \"" + destiny + "\""
#print cmd
output = os.popen(cmd).read()

Expand Down

0 comments on commit 31f7813

Please sign in to comment.