def comment(): if is_logged(session): if request.method == "POST": db.computers.update({"_id": ObjectId(request.form["id"])}, {"$set": {"comment": request.form["comment"]}}) return redirect(url_for("computers")) else: return redirect(url_for("login"))
def scan(id=None): if is_logged(session): if len(str(id)) == 24 and id != None: computer = db.computers.find_one({"_id": ObjectId(id)}) thread = Thread(target=script.nmap.nmapscan, args=(db, computer["ip"])) thread.start() info = "Scan of %s start" % computer["ip"] return redirect(url_for("computers", info=info)) else: thread = Thread(target=script.ntbscan.nbtscan, args=(db,)) thread.start() info = "Scan of netbios network start" return redirect(url_for("computers", info=info)) else: return redirect(url_for("login"))
def computers(id=None): if is_logged(session): info = False if id: db.computers.update({"_id": ObjectId(id)}, {"$set": {"check": True}}) if request.method == "POST": computer = {} computer["hostname"] = request.form["hostname"] computer["ip"] = request.form["ip"] computer["mac"] = "" db.computers.insert(computer) if request.method == "GET": if request.args.get("info"): info = request.args.get("info") if request.args.get("del"): id = request.args.get("del") db.computers.remove({"_id": ObjectId(id)}) info = "Computer remove!" computers = db.computers.find().sort([("ip", pymongo.ASCENDING)]) return render_template("computers.html", computers=computers, info=info) else: return redirect(url_for("login"))
def index(): if is_logged(session): return redirect(url_for("computers")) else: return redirect(url_for("login"))