Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding windows compatibility #69

Merged
merged 1 commit into from Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions appmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
# limitations under the License.
###

import os, sys, argparse, time, codecs, binascii, frida, json, traceback, subprocess
import os, sys, argparse, time, codecs, binascii, frida, json, traceback, subprocess, tempfile
from flask import Flask, request, render_template
from termcolor import colored
import database as db
import platform as platform_module

print """
___ .______ .______ .___ ___. ______ .__ __.
Expand All @@ -37,7 +38,8 @@

device = ''
session = ''
merged_script_path = '/tmp/merged.js'
temp_dir = tempfile.mkdtemp()
merged_script_path = os.path.join(temp_dir,'merged.js')
APP_LIST = []


Expand Down Expand Up @@ -76,8 +78,9 @@ def monitor_page():
def landing_page():
global APP_LIST, DB_MAP

for root, dirs, files in os.walk('./app_dumps'):
path = root.split('/')
app_dumps_dir = os.path.join('.','app_dumps')
for root, dirs, files in os.walk(app_dumps_dir):
path = root.split(os.sep)
for file in files:
file_path = os.path.join(root, file)
if file_path.endswith('.db'):
Expand Down Expand Up @@ -124,7 +127,7 @@ def init_opts():
list_apps = int(results.list_apps)
spawn = int(results.spawn)

output_dir = results.output_dir if results.output_dir else './app_dumps'
output_dir = results.output_dir if results.output_dir else os.path.join('.','app_dumps')

report_name = results.report if results.report else app_name

Expand Down Expand Up @@ -179,7 +182,11 @@ def on_detached():


def on_message(message, data):
current_time = time.strftime('%b %d %Y %l:%M %p', time.localtime())
os_string = platform_module.system()
if os_string == "Windows":
current_time = time.strftime('%b %d %Y %I:%M %p', time.localtime())
else:
current_time = time.strftime('%b %d %Y %l:%M %p', time.localtime())

if not os.path.exists(output_dir):
os.makedirs(output_dir)
Expand Down
8 changes: 7 additions & 1 deletion database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@
###

import dataset, json, time, htmlentities
import platform as platform_module
from xml.sax.saxutils import escape

def save_to_database(db_path, str_json):
try:
str_json = json.loads(str_json.replace("\n", "<br />").replace("\r", "<br />"), strict=False)
db = dataset.connect('sqlite:///%s' % (db_path.replace("'", "_")))
table = db['api_captures']
table.insert(dict(time=time.strftime('%b %d %Y %l:%M %p', time.localtime()),
os_string = platform_module.system()
if os_string == "Windows":
formatted_time = time.strftime('%b %d %Y %I:%M %p', time.localtime())
else:
formatted_time = time.strftime('%b %d %Y %l:%M %p', time.localtime())
table.insert(dict(time=formatted_time,
operation=str_json['txnType'],
artifact=json.dumps(str_json['artifact']),
method=str_json['method'],
Expand Down
6 changes: 4 additions & 2 deletions viewreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ def landing_page():
global APP_LIST
global DB_MAP
APP_LIST = []
for root, dirs, files in os.walk('./app_dumps'):
path = root.split('/')

app_dumps_dir = os.path.join('.','app_dumps')
for root, dirs, files in os.walk(app_dumps_dir):
path = root.split(os.sep)
for file in files:
file_path = os.path.join(root, file)
if file_path.endswith('.db'):
Expand Down