kanna
This commit is contained in:
parent
cb88571c53
commit
5b6bdefbec
|
@ -13,6 +13,12 @@
|
|||
position: relative
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 760px) {
|
||||
.pan {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
abbr:hover::after {
|
||||
background: #add8e6;
|
||||
border-radius: 4px;
|
||||
|
@ -103,6 +109,7 @@
|
|||
let user = document.getElementById('user').value
|
||||
let pass = document.getElementById('pass').value
|
||||
let out = {}
|
||||
|
||||
Object.assign(out, { json: true, enc: true, sid: sid }, { data: nodersa(pub, 'pkcs8-public').encrypt({ user: user, pass: pass, date: new Date() }, 'base64') })
|
||||
|
||||
xhr.send(JSON.stringify(out))
|
||||
|
@ -139,8 +146,13 @@
|
|||
submit()
|
||||
}
|
||||
};
|
||||
let mypriv, mypub
|
||||
async function load() {
|
||||
sendnoenc('pub.key', { sid: sid })
|
||||
let kekw = await nodersa({ b: 512 })
|
||||
mypriv = await kekw.exportKey('pkcs1-private')
|
||||
mypub = await kekw.exportKey('pkcs8-public')
|
||||
console.log(mypub)
|
||||
sendnoenc('pub.key', { sid: sid, pub: mypub })
|
||||
readTextFile("kanna.txt").then((kanna) => {
|
||||
let left = -300;
|
||||
let top = -40;
|
||||
|
@ -155,7 +167,9 @@
|
|||
document.body.innerHTML += "<div style='position:absolute;bottom:20px;right:50px;user-select: none;cursor:pointer;' onclick=\"location.href='mailto:grantsquires@disroot.org';\"><tt>need a account? contact grantsquires@disroot.org<sub><sub>(click here)</sub></sub></tt></div>"
|
||||
*/
|
||||
deg = 10
|
||||
document.body.innerHTML += "<div id='pan' style='position:absolute;bottom:0px;right:0px;width:600px;height:100px;background-color:rgba(150,150,150,0.3);box-shadow: 0px 0px 20px 12px rgba(0,0,0,0.5);backdrop-filter:hue-rotate(10deg) blur(5px);border-radius:10px 0px 0px 0px;'></div>"
|
||||
document.body.innerHTML += "<div id='pan' style='display: flex;flex-direction: column;position:absolute;bottom:0px;right:0px;width:45%;height:100px;background-color:rgba(150,150,150,0.3);box-shadow: 0px 0px 20px 12px rgba(0,0,0,0.1);backdrop-filter:hue-rotate(10deg) blur(5px);border-radius:10px 0px 0px 0px;'>\
|
||||
<div style='padding:30px;padding-bottom:40px;'>user:<input style='padding:5px;' placeholder='root' type='text' id='user' name='user'>pass:<input style='padding:5px;' type='password' id='pass' name='pass'> <input style='background-color:rgba(200,200,200,.3);border-color:rgba(80,80,80,.1);border:line;border-radius:4px;padding:5px;' type='button' value='submit' onclick='submit()'></div>"
|
||||
document.body.innerHTML += "</div>"
|
||||
setInterval(() => {
|
||||
deg += 10
|
||||
|
||||
|
|
29
index.ts
29
index.ts
|
@ -9,14 +9,23 @@ app.use(bodyParser.urlencoded({ extended: false }));
|
|||
app.use(bodyParser.json());
|
||||
const NodeRSA = require('node-rsa');
|
||||
var ip = require("ip")
|
||||
//let priv = '';
|
||||
|
||||
function log(m:string){
|
||||
var date = new Date;
|
||||
console.log('['+date.getHours()+':'+date.getMinutes()+':'+date.getSeconds()+'] ' + m)
|
||||
}
|
||||
interface keyring{
|
||||
[sid: string]: string,
|
||||
[sid: string]: {
|
||||
mypub:string,
|
||||
theirpub:string,
|
||||
mypriv:string,
|
||||
},
|
||||
}
|
||||
let keyring = {} as keyring
|
||||
let key:any;
|
||||
app.listen(port,'0.0.0.0', () => {
|
||||
|
||||
log(`kanna is on http://${ip.address()}:${port} click on me click on me! :3`)
|
||||
})
|
||||
app.get('/', (req:any, res:any) => {
|
||||
res.sendFile(__dirname+"/html/index.html")
|
||||
})
|
||||
|
@ -32,12 +41,15 @@ app.get('/src/lights-out.gif', (req:any, res:any) => {
|
|||
app.get('/src/kanna.gif', (req:any, res:any) => {
|
||||
res.sendFile(__dirname+'/src/kanna.gif')
|
||||
})
|
||||
app.post('/pub.key', async (req:{body:{json:boolean,sid:keyof keyring}}, res:any) => {
|
||||
app.post('/pub.key', async (req:{body:{json:boolean,sid:keyof keyring,pub:string}}, res:any) => {
|
||||
if(req.body.json){
|
||||
|
||||
|
||||
const key = new NodeRSA({b: 1024});
|
||||
keyring[req.body.sid]=key.exportKey('pkcs1-private')
|
||||
keyring[req.body.sid]={mypriv:key.exportKey('pkcs1-private'),
|
||||
mypub:key.exportKey('pkcs8-public'),
|
||||
theirpub:req.body.pub}
|
||||
console.log(keyring)
|
||||
res.send(key.exportKey('pkcs8-public'))
|
||||
}
|
||||
})
|
||||
|
@ -45,13 +57,13 @@ app.post('/pub.key', async (req:{body:{json:boolean,sid:keyof keyring}}, res:any
|
|||
app.post('/login/submit', async (req:{body:{json:boolean,enc:boolean,data:string,sid:keyof keyring}}, res:any) => {
|
||||
const key = new NodeRSA({b: 1024})
|
||||
|
||||
key.importKey(keyring[req.body.sid],'pkcs1-private')
|
||||
key.importKey(keyring[req.body.sid].mypriv,'pkcs1-private')
|
||||
let dec:{user:string,pass:string} = JSON.parse((atob(key.decrypt(req.body.data,'base64','base64'))))
|
||||
|
||||
let users = JSON.parse(readFileSync('json/user.json').toString())
|
||||
for(let user of users){
|
||||
let use=user as typeof users
|
||||
console.log(use)
|
||||
log(use)
|
||||
if(user.name==dec.user&&user.pass==dec.pass){
|
||||
res.send('logged in, hello!')
|
||||
}
|
||||
|
@ -59,6 +71,3 @@ app.post('/login/submit', async (req:{body:{json:boolean,enc:boolean,data:string
|
|||
})
|
||||
|
||||
|
||||
app.listen(port,'0.0.0.0', () => {
|
||||
console.log(`kanna is on http://${ip.address()}:${port} click on me click on me! :3`)
|
||||
})
|
Loading…
Reference in a new issue