Commit 7bcad18c authored by Edvard Rejthar's avatar Edvard Rejthar

everything seems to work :o #20

parent a1c829f4
/nbproject/private/
\ No newline at end of file
{
"abort_on_missing": false,
"check_memory": false,
"enable_e10s": false,
"is-sdk-bundled": false,
"jetpackID": "mdmaug@jetpack",
"loader": "addon-sdk/lib/sdk/loader/cuddlefish.js",
"main": "main",
"mainPath": "mdmaug/main",
"manifest": {
"mdmaug/main": {
"docsSHA256": null,
"jsSHA256": "497a1082ce489b39d8f17e63e14015b7f3ea023f4af555ccc15ef740d6f003e7",
"moduleName": "main",
"packageName": "mdmaug",
"requirements": {
"chrome": "chrome",
"sdk/base64": "sdk/base64",
"sdk/page-mod": "sdk/page-mod",
"sdk/tabs": "sdk/tabs",
"sdk/self": "sdk/self",
"sdk/tabs/utils": "sdk/tabs/utils",
"sdk/timers": "sdk/timers",
"sdk/ui/button/action": "sdk/ui/button/action",
"sdk/window/utils": "sdk/window/utils"
},
"sectionName": "lib"
}
},
"metadata": {
"addon-sdk": {
"description": "Add-on development made easy.",
"keywords": [
"javascript",
"engine",
"addon",
"extension",
"xulrunner",
"firefox",
"browser"
],
"license": "MPL 2.0",
"name": "addon-sdk"
},
"mdmaug": {
"author": "Edvard Rejthar",
"description": "mdmaug csirt.cz detection tool",
"license": "MPL 2.0",
"main": "main",
"name": "mdmaug",
"version": "0.1"
}
},
"name": "mdmaug",
"parseable": false,
"preferencesBranch": "mdmaug@jetpack",
"sdkVersion": "1.17",
"staticArgs": {},
"verbose": false
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?><!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --><RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>mdmaug@jetpack</em:id>
<em:version>0.1</em:version>
<em:type>2</em:type>
<em:bootstrap>true</em:bootstrap>
<em:unpack>false</em:unpack>
<!-- Firefox -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>26.0</em:minVersion>
<em:maxVersion>30.0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>mdmaug</em:name>
<em:description>mdmaug csirt.cz detection tool</em:description>
<em:creator>Edvard Rejthar</em:creator>
</Description>
</RDF>
\ No newline at end of file
......@@ -21,7 +21,7 @@ const data = require('sdk/self').data;
// **********
//profile dir
// **********
logDir = "/home/mdmaug/.cache/mdmaug-scans/_tmp/" //"/tmp/mdm/"; temp byl maly 200 MB - a zabira cennou RAMku
logDir = "/opt/mdmaug/.cache/mdmaug-scans/_tmp/" //"/tmp/mdm/"; temp byl maly 200 MB - a zabira cennou RAMku
profileDir = OS.Constants.Path.profileDir;
profileName = profileDir.substr(profileDir.lastIndexOf("/") + 1);
console.log("profile name: " + profileName);
......
......@@ -103,3 +103,7 @@ user_pref("toolkit.startup.max_resumed_crashes", -1);
user_pref("toolkit.telemetry.cachedClientID", "8b5a3bbc-dcb3-44f6-bd86-f0fa1fd2fa15");
user_pref("toolkit.telemetry.previousBuildID", "20170201180315");
user_pref("toolkit.telemetry.reportingpolicy.firstRun", false);
// I think these will be unuseful as of Firefox v 50+ or so
user_pref("xpinstall.signatures.required", false);
user_pref("xpinstall.whitelist.required", false);
\ No newline at end of file
# DOESNT WORK – process can know its run in docker
FROM ubuntu:16.04
#RUN apt update && apt install -y \
python3 \
python3-pip \
xvfb \
firefox \
# && pip3 install \
xvfbwrapper \
pymysql
RUN ./INSTALL
#RUN apt-get -y update && apt-get install -y fortunes
#CMD /usr/games/fortune -a | cowsay
CMD i="0";while [ $i -lt 4 ]; do echo "1";sleep 1; done
#CMD firefox
\ No newline at end of file
#!/bin/bash
# Installation file for MDMaug
# If environment variable LC_ALL is empty, you may have some troubles with setting system locale as I had.
DESTINATION=/opt/mdmaug
useradd -m -d $DESTINATION mdmaug
cp * /opt/mdmaug
PROFILE_COUNT=21
# sometimes, there is no repository with pip on the machine, trying to add some sources
apt install software-properties-common
add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"
apt update
apt-get install firefox python3 mariadb-server # X should be distributed with python python3-pip
pip3 install xvfbwrapper pymysql peewee jinja2 pyyaml bs4 pygments pillow requests
# mariadb setup
mysql -u root < /opt/mdmaug-installer/mdmaug-installation.sql # populate db
mysql -uroot -e "CREATE USER 'mdmaug'@'localhost' IDENTIFIED BY 'fidFDSs676'; GRANT ALL PRIVILEGES ON mdmaug. * TO 'mdmaug'@'%';" # new user
# adding user the server will be run under
useradd -m -d $DESTINATION mdmaug
# copy all important files
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
cp -r mdmaug $DESTINATION
cp -r .mozilla $DESTINATION
cp *.md $DESTINATION
cd $DESTINATION
# copy firefox profiles (about:config is stored at prefs.js file)
for(( i=1; i<=$((PROFILE_COUNT-1)); i++ ))
do
DEST=$DESTINATION/.mozilla/firefox/$i/
[ -d $DEST ] && "profile $i already exists, wont change" || cp -R .mozilla/firefox/0 $DEST
done
chown mdmaug:mdmaug -R $DESTINATION
apt-get install firefox python3 python3-pip xvfb git
pip3 install xvfbwrapper pymysql
\ No newline at end of file
......@@ -4,28 +4,21 @@ Scans a website for a sign of a parasite hosts or commands.
## Installation
* ```git clone git@gitlab.labs.nic.cz:csirt/mdmaug.git /tmp/mdmaug && /tmp/mdmaug/INSTALL```
* ```git clone git@gitlab.labs.nic.cz:csirt/mdmaug.git /tmp/mdmaug```
* edit config.py
* ```/tmp/mdmaug/INSTALL```
### Notes
* If you use NoScript, make sure it doesn't block the MDM-Augmented server.
* Certificate error: Make sure that the browser doesn't blockt the MDM-Augmented server if used from MDM.
* If you want other count of profiles than 21, change INSTALL + config.py + profiles.ini
* You may put ```03 1,7,13,19 * * * ~/mdmaug-launch``` in ```crontab -e``` of user mdmaug.
## older to be distributed
Zajistim, ze na systemu bezi Firefox a nastavim mu pocet profilu, jaky chci. Podle toho upravim Config.profileCount.
Lze otestovat, ze firefox prebira z prikazove radky parametry (muze se stat, ze je stane nastaveny zastupce v /usr/bin) pri vytvareni profilu: firefox -P
## What is done to Firefox profiles?
We want no block nor safebrowsing warning. If you created the profiles manually, you'd use ```firefox -P```, the profiles names being: 0,1...
V prohlizeci, kde pojede MDMko, se pro test pripojte na https://172.20.7.10:8000 a pridejte server mezi vyjimky. (Jinak se prohlížeč nepřipojí a python vrátí SSLError - unknown ca.)
Protoze MDM je pres https, je https i MDM-Augmented server. Vykaslal jsem se na certifikat, sam si jej podepsav. Zabte me.
Zabezpecte, aby NoScript neblokoval csirt.csirt.office.nic.cz (ani 172.20.7.10).
Jak ve FF vytvorit profily?
* firefox -P je vsechny vytvorim, nazvu je cisly 0,1...
* jeden profil nastavim (security - nechci zadny block ani safebrowsing warning)
* about:config
* browser.sessionstore.resume_from_crash nastavit na false
* browser.sessionstore.max_resumed_crashes nastavit na -1
......@@ -42,22 +35,16 @@ Scans a website for a sign of a parasite hosts or commands.
* privacy.sanitize.sanitizeOnShutdown = true
* privacy.clearOnShutdown.* = true
* network.http.accept-encoding.secure
* ... see prefs.js
## older to be distributed
* mdmaug extension
- cfx xpi vygeneruje 'mdmaug.xpi'
- prejmenuju na zip
- do složky ~/.mozilla/extensions/mdmaug@jetpack (id tvori ještě přídomek @jetpack)
- vkopiruju obsah slozky zipu xpi
- prefs.js všech profilů obsahuje extensions.autoDisableScopes = "0"
* tento profile pak zkopiruju do ostatnich slozek
- about:config je v souboru prefs.js
- profily jde bezpecne prejmenovat v souboru profiles.ini
- chown: FF jede pod uzivatele mdmaug, ne pod rootem. Do Debianu se musi FF stahnout z taru. Pokud nemuze zapisovat do slozky pri vytvoreni profilu, zkusim chown mdmaug:mdmaug pro celou home slozku, nebo alespon chown mdmaug:mdmaug -hR .mozilla
- Při jednorázovém updatu prefs.js - staci kdyz ho vkopiruju do složky profilu 0, správně nastavím cesty v bin/profile_copy a spustím...
* pozor na prava, kdyztak sudo chown -R mdmaug /home/mdmaug/
- vkopiruju obsah slozky zipu xpi
......@@ -71,4 +58,12 @@ Xhttps://csirt.csirt.office.nic.cz:8000/rest/analyze/atlas.cz -> vsechny odkazy
XZabezpecte, aby NoScript neblokoval csirt.csirt.office.nic.cz (ani 172.20.7.10).
Dependencies:
pip3.4 install pymysql ... vono si to řekne
\ No newline at end of file
pip3.4 install pymysql ... vono si to řekne
XZabezpecte, aby NoScript neblokoval csirt.csirt.office.nic.cz (ani 172.20.7.10).
Zajistim, ze na systemu bezi Firefox a nastavim mu pocet profilu, jaky chci. Podle toho upravim Config.profileCount.
Lze otestovat, ze firefox prebira z prikazove radky parametry (muze se stat, ze je stane nastaveny zastupce v /usr/bin) pri vytvareni profilu: firefox -P
V prohlizeci, kde pojede MDMko, se pro test pripojte na https://172.20.7.10:8000 a pridejte server mezi vyjimky. (Jinak se prohlížeč nepřipojí a python vrátí SSLError - unknown ca.)
Protoze MDM je pres https, je https i MDM-Augmented server. Vykaslal jsem se na certifikat, sam si jej podepsav. Zabte me.
- chown: FF jede pod uzivatele mdmaug, ne pod rootem. Do Debianu se musi FF stahnout z taru. Pokud nemuze zapisovat do slozky pri vytvoreni profilu, zkusim chown mdmaug:mdmaug pro celou home slozku, nebo alespon chown mdmaug:mdmaug -hR .mozilla
* pozor na prava, kdyztak sudo chown -R mdmaug /home/mdmaug/
\ No newline at end of file
# MDM-Augmented
<<<<<<< HEAD
Scans a website for a sign of a parasite hosts or commands.
=======
## Installation
>>>>>>> 241efbd287bd7b18a7247f16f18c3b2937049338
## Installation
* ```git clone git@gitlab.labs.nic.cz:csirt/mdmaug.git /tmp/mdmaug && /tmp/mdmaug/INSTALL```
* edit config.py
<<<<<<< HEAD
### Notes
=======
## older to be distributed
>>>>>>> 241efbd287bd7b18a7247f16f18c3b2937049338
* If you use NoScript, make sure it doesn't block the MDM-Augmented server.
* Certificate error: Make sure that the browser doesn't blockt the MDM-Augmented server if used from MDM.
## older to be distributed
Zajistim, ze na systemu bezi Firefox a nastavim mu pocet profilu, jaky chci. Podle toho upravim Config.profileCount.
Lze otestovat, ze firefox prebira z prikazove radky parametry (muze se stat, ze je stane nastaveny zastupce v /usr/bin) pri vytvareni profilu: firefox -P
Jak ve FF vytvorit profily?
* firefox -P je vsechny vytvorim, nazvu je cisly 0,1...
* jeden profil nastavim (security - nechci zadny block ani safebrowsing warning)
* about:config
* browser.sessionstore.resume_from_crash nastavit na false
* browser.sessionstore.max_resumed_crashes nastavit na -1
* toolkit.startup.max_resumed_crashes = -1 (protoze i kdyz prohlizec nekdy killnu, nesmi me pri spusteni otravovat gui popupem)
* network.http.accept-encoding = "" # ukladame streamy, ale neumim je rozzipovat
* extensions.autoDisableScopes = "0" # moznost instalovat ze vsech umisteni
* browser.selfsupport.url = "" # tato moznost normalne v about:config neni, ale omezuje to nejake zbytecnou telemetrii, viz Mozilla Heartbeat
* # nepamatovat si historii (Preferences / Privacy / Firefox will use custom settings for history / Clear history when closes / Setting / All)
* # nejsem si jist, nakolik to funguje, zrejme dost
* privacy.clearOnShutdown.offlineApps = true
* privacy.clearOnShutdown.passwords = true
* privacy.clearOnShutdown.siteSettings = true
* privacy.sanitize.didShutdownSanitize = true
* privacy.sanitize.sanitizeOnShutdown = true
* privacy.clearOnShutdown.* = true
* network.http.accept-encoding.secure
* mdmaug extension
- cfx xpi vygeneruje 'mdmaug.xpi'
- prejmenuju na zip
- do složky ~/.mozilla/extensions/mdmaug@jetpack (id tvori ještě přídomek @jetpack)
- vkopiruju obsah slozky zipu xpi
- prefs.js všech profilů obsahuje extensions.autoDisableScopes = "0"
* tento profile pak zkopiruju do ostatnich slozek
- about:config je v souboru prefs.js
- profily jde bezpecne prejmenovat v souboru profiles.ini
- chown: FF jede pod uzivatele mdmaug, ne pod rootem. Do Debianu se musi FF stahnout z taru. Pokud nemuze zapisovat do slozky pri vytvoreni profilu, zkusim chown mdmaug:mdmaug pro celou home slozku, nebo alespon chown mdmaug:mdmaug -hR .mozilla
- Při jednorázovém updatu prefs.js - staci kdyz ho vkopiruju do složky profilu 0, správně nastavím cesty v bin/profile_copy a spustím...
* pozor na prava, kdyztak sudo chown -R mdmaug /home/mdmaug/
## ok; to be deleted
Xhttps://csirt.csirt.office.nic.cz:8000/rest/analyze/atlas.cz -> vsechny odkazy pro MDMko.
XJak se instaluje? Python3. Pip. apt-get nainstaluje Xvfb a pip nainstaluje xvfbwrapper.
XV prohlizeci, kde pojede MDMko, se pro test pripojte na https://172.20.7.10:8000 a pridejte server mezi vyjimky. (Jinak se prohlížeč nepřipojí a python vrátí SSLError - unknown ca.)
Protoze MDM je pres https, je https i MDM-Augmented server. Vykaslal jsem se na certifikat, sam si jej podepsav. Zabte me.
XZabezpecte, aby NoScript neblokoval csirt.csirt.office.nic.cz (ani 172.20.7.10).
Dependencies:
pip3.4 install pymysql ... vono si to řekne
\ No newline at end of file
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
CREATE DATABASE `mdmaug` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */;
USE `mdmaug`;
DROP TABLE IF EXISTS `export`;
CREATE TABLE `export` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Dates of realized Turris export';
DROP TABLE IF EXISTS `status`;
CREATE TABLE `status` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(5) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='IP status';
INSERT INTO `status` (`id`, `name`) VALUES
(0, 'n/a'),
(1, 'allow'),
(2, 'log'),
(3, 'block');
DROP TABLE IF EXISTS `turris`;
CREATE TABLE `turris` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When we encountered the IP on a page.',
`status` int(11) NOT NULL DEFAULT '0' COMMENT 'n/a, allow, log, block',
`date` int(11) NOT NULL,
`ip` varchar(45) COLLATE utf8_bin DEFAULT NULL,
`port` int(11) NOT NULL,
`url` varchar(255) COLLATE utf8_bin NOT NULL,
`block` int(11) NOT NULL,
`remoteHost` varchar(255) COLLATE utf8_bin NOT NULL,
`otherDetails` varchar(255) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`),
KEY `status` (`status`),
CONSTRAINT `turris_ibfk_1` FOREIGN KEY (`status`) REFERENCES `status` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `whitelist`;
CREATE TABLE `whitelist` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`domain` varchar(255) COLLATE utf8_bin NOT NULL COMMENT '2nd level domain',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'when whitelisted',
PRIMARY KEY (`id`),
UNIQUE KEY `domain` (`domain`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='2nd domains that are whitelisted automatically.';
INSERT INTO `whitelist` (`id`, `domain`, `timestamp`) VALUES
(26, 'mozilla.org', '2015-02-05 19:21:15'),
(27, 'mozilla.net', '2015-02-05 19:21:22'),
(28, 'digicert.com', '2015-02-05 19:21:30'),
(29, 'google.com', '2015-02-05 19:21:36'),
(30, 'google-analytics.com', '2015-02-05 19:23:16'),
(31, 'googlesyndication.com', '2015-02-05 19:24:00'),
(32, 'gstatic.com', '2015-02-05 19:25:45'),
(33, 'google.cz', '2015-04-27 11:11:10'),
(36, 'w3.org', '2015-05-07 14:38:05'),
(37, 'googleapis.com', '2015-05-07 14:48:41'),
(38, 'mozilla.com', '2015-05-07 14:55:38'),
(39, 'doubleclick.net', '2015-05-07 17:48:20'),
(41, 'cloudfront.net', '2015-05-10 18:57:10'),
(42, 'googleadservices.com', '2015-06-11 15:23:12');
-- 2017-04-07 05:06:19
\ No newline at end of file
su - mdmaug -c 'cd /home/mdmaug/mdmaug/ ; python3 mdmaug.py'
killall python3 #pri Ctrl+C v prikazu su se uzavre jen terminal, ale ne uz python skript. Takhle to zas zabije veskery Python, ale sandboxovy-zavirovany uzivatel mdmaug stejne ma byt jen na spousteni tohohle skriptu.
\ No newline at end of file
pkill python3 #pri Ctrl+C v prikazu su se uzavre jen terminal, ale ne uz python skript. Takhle to zas zabije veskery Python, ale sandboxovy-zavirovany uzivatel mdmaug stejne ma byt jen na spousteni tohohle skriptu.
\ No newline at end of file
......@@ -95,12 +95,13 @@ class ScanController:
logfile = logDir + "log{}.log".format(self.profile)
#max_time = 3 # XXX
#,nsSocketTransport:5,nsStreamPump:5,nsHostResolver:5
print("({}) FF -P {} -no-remote {}".format(self.profile,self.profile,self.url))
command = "export NSPR_LOG_MODULES=timestamp,nsHttp:5 ; export NSPR_LOG_FILE={} ; {} -P {} -no-remote '{}'".format(logfile, Config.browser, self.profile , "http://localhost/redirect/" + self.url) #,nsSocketTransport:5,nsStreamPump:5,nsHostResolver:5
#ukoncit Config.browser, pokud tento nezvladne sam (vse musi byt v jednom prikazu, nebot mezi subprocessy se nededi $!)
command = "export NSPR_LOG_MODULES=timestamp,nsHttp:5 ; export NSPR_LOG_FILE={} ; {} -P {} -no-remote '{}'".format(logfile, Config.browser, self.profile , "http://localhost/redirect/" + self.url) # http://localhost/redirect/ gets stripped by the extension
# terminate Config.browser if hes not able to (everything has to be in single command because there is no heritance of $! amongst subprocesses)
command += " & echo $!;ii=0; while [ -n \"`ps -p $! | grep {}`\" ];do echo \"({}) running\" ;ii=$((ii+1)); if [ $ii -gt {} ]; then echo '({}) kill';kill $!; break;fi; sleep 1; done".format(Config.browser, self.profile , Config.MAX_BROWSER_RUN_TIME,self.profile) #(pokud bezi proces $! (posledni backgroudovany process), spi 1 s)
#> /dev/null
#print(command)
print(command)
subprocess.call([command], shell=True)
print("({}) stopped!".format(self.profile))
# shromazdit informace z analyz
......
......@@ -6,11 +6,11 @@ from peewee import MySQLDatabase
class Config:
profileCount = 21 # pocet profilu vytvorenych ve firefoxu. Tyto je treba vytvorit rucne. Nazev profilu je cislo - 0,1...
browser = 'firefox' # iceweasel, firefox. Ktery prohlizec se spousti.
configFile = '/home/mdmaug/.cache/mdmaug-scans/_tmp/queue.cache' # RAM disk byl maly: '/tmp/mdm/queue.cache'
configFile = '/opt/mdmaug/.cache/mdmaug-scans/_tmp/queue.cache' # RAM disk byl maly: '/tmp/mdm/queue.cache'
APP_PORT = 8000
APP_DOMAIN = 'https://172.20.7.10:' + str(APP_PORT) #csirt.csirt.office.nic.cz
LOG_DIR = "/home/mdmaug/.cache/mdmaug-scans/_tmp/" # X /tmp/mdm/
CACHE_DIR = "/home/mdmaug/.cache/mdmaug-scans/"
APP_DOMAIN = 'https://217.31.202.41:' + str(APP_PORT) #csirt.csirt.office.nic.cz
LOG_DIR = "/opt/mdmaug/.cache/mdmaug-scans/_tmp/" # X /tmp/mdm/
CACHE_DIR = "/opt/mdmaug/.cache/mdmaug-scans/"
myDB = ""
lock = threading.RLock() # doufam, ze kdyz je lock tady, ze je funknci. Closure...? XX nejak otestovat
THUMBNAIL_SIZE = 640, 640
......@@ -22,7 +22,7 @@ class Config:
# XX resim problem peewee.OperationalError: (2006, "MySQL server has gone away (BrokenPipeError(32, 'Broken pipe'))") po 7 hodinach timeoutu
# XX kupodivu pripojeni nemuze byt v dbp DBModel.connect. Prestoze type je pak spravne (MySQLDatabase), nic udelat nejde a pokusy o select konci NoneType.
print("Connecting to DB.")
Config.myDB = MySQLDatabase("mdmaug", host='172.20.7.10', port=3306, user="root", passwd="lopuch") # XX dal jsem pryc: , threadlocals=False
Config.myDB = MySQLDatabase("mdmaug", host='localhost', port=3306, user="mdmaug", passwd="fidFDSs676") # XX dal jsem pryc: , threadlocals=False
Config.myDB.register_fields({'primary_key': 'BIGINT AUTOINCREMENT'})
Config.connect()
......@@ -47,6 +47,7 @@ class Domains:
return 'http://pdns.cert.at/p/dns?qry=' + ip
def ip2pdnsDomains(ip):
return None #24 doesnt work
try:
# XX mohl bych sortovat dle 2nd domeny. Pripadne oriznout 3rd domenu, nechat jen 2nd. Tam ale musim osetrit problemove dvojite tld - co.uk, gov.ua...
pdns = urllib.request.urlopen(Domains.getPdnsLink(ip)).read().decode("utf-8")
......@@ -59,6 +60,7 @@ class Domains:
def ip2countryAndCity(ip):
return None, None #23 service down
try:
hostipApi = urllib.request.urlopen('http://api.hostip.info/get_html.php?ip=' + ip + '&position=true').read().decode("utf-8").split("\n")
#['Country: CZECH REPUBLIC (CZ)', 'City: Prague', '', 'Latitude: 50.0833', 'Longitude: 14.4333', 'IP: 109.123.209.188', '']
......
......@@ -70,12 +70,12 @@ class Rest:
def reset():
logging.debug("resetting running browsers")
logging.debug("resetting running browsers")
#smazat frontu
with open(Config.configFile, 'w') as f:
json.dump({}, f)
#zabit zamrzle prohlizece
subprocess.call(["killall", Config.browser])
subprocess.call(["pkill", Config.browser])
......
......@@ -12,10 +12,8 @@ from lib.dbp import Export, DbModel
env = Environment()
env.loader = FileSystemLoader(".")
class Server (SimpleHTTPRequestHandler):
def favicon(self):
with open('favicon.ico', 'rb') as f:
self.output(f.read(), "image/x-icon")
......@@ -50,7 +48,7 @@ class Server (SimpleHTTPRequestHandler):
with open(url, type) as f:
self.output(f.read(), contentType=mimetypes.guess_type(url))
def do_GET(self):
def do_GET(self):
#XX Config.myDB.get_conn() # vytvorit spojeni, kdyby po 9 hodinach vypadlo. (Funguje?)
#from lib.dbp import Whitelist
DbModel.assureConnection()
......
#!/bin/bash
# This file may be placed to the ~ location and launched by CRON. 03 1,7,13,19 * * * ~/mdmaug-launch
# This file may be launched by CRON. 03 1,7,13,19 * * * ~/mdmaug/mdmaug-launch
echo "mdmaug-launch start" >> ~/log.log
pkill -f mdmaug.py
pkill -f Xvfb
export PYTHONPATH=$PYTHONPATH:/home/mdmaug/mdmaug/
cd ~/mdmaug && ./mdmaug.py 2>&1 | /usr/bin/logger -t yourtag
export PYTHONPATH=$PYTHONPATH:/opt/mdmaug/mdmaug/
cd /opt/mdmaug/mdmaug && ./mdmaug.py 2>&1 | /usr/bin/logger -t yourtag
whoami >> ~/log.log
\ No newline at end of file
#!/usr/local/bin/python3
#!/usr/bin/env python3
import logging
logging.basicConfig(level=logging.DEBUG, format="%(message)s")
#logging.basicConfig(level=logging.WARNING, format="%(levelname)s: %(message)s",filename="logger.log")
......@@ -43,10 +43,12 @@ httpd.socket = ssl.wrap_socket(httpd.socket,
certfile='python.pem', #spojenej private + cert, http://stackoverflow.com/questions/19705785/python-3-https-webserver
ssl_version=ssl.PROTOCOL_TLSv1)
#spustit server
#DbModel.connect()
#httpd.serve_forever()
#for i in range(21): # Config.profileCount
print('Listening at https://0.0.0.0:{}'.format(Config.APP_PORT) , flush=True)
for i in range(2): # Config.profileCount
threading.Thread(target=httpd.serve_forever).start()
#DbModel.disconnect()
......
......@@ -12,7 +12,7 @@
if (document.location.href.indexOf("https://mdm.nic.cz/detail/") === 0) {
var KEY = {DOWN: 40, UP: 38, LEFT: 37, RIGHT: 39, ALT: 17, C: 67, L: 76, N: 78, W: 87, N1: 49, N2: 50, N3: 51, N4: 52, N5: 53, N6: 54, N7: 55, N8: 56, N9: 57, F: 70, S: 83};
$ = j;
APP_HOST = "https://172.20.7.10:8000";
APP_HOST = "https://217.31.202.41:8000";
$(function () {
$('#detail_tabs').tabs('option', 'active', 3);//XX nejprve jdeme na tab korespondence (nevim, jestli tohle funguje)
......
java.lib.path=
platform.active=Python_3.5.1
python.lib.path=
src..mozilla.dir=.mozilla
src.mdmaug.dir=mdmaug
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.python.project</type>
<configuration>
<data xmlns="http://nbpython.dev.java.net/ns/php-project/1">
<name>mdmaug</name>
<sources>
<root id="src..mozilla.dir"/>
<root id="src.mdmaug.dir"/>
</sources>
<tests/>
</data>
</configuration>
</project>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment