From 5b6bdefbec79245a93d38ea423738322580e73b7 Mon Sep 17 00:00:00 2001 From: grant-kun Date: Tue, 4 Oct 2022 09:00:27 -0500 Subject: kanna --- html/index.html | 18 ++++++++++++++++-- index.ts | 31 ++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/html/index.html b/html/index.html index 0fb27f9..4dcc8de 100644 --- a/html/index.html +++ b/html/index.html @@ -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 += "
need a account? contact grantsquires@disroot.org(click here)
" */ deg = 10 - document.body.innerHTML += "
" + document.body.innerHTML += "
\ +
user:pass:
" + document.body.innerHTML += "
" setInterval(() => { deg += 10 diff --git a/index.ts b/index.ts index 2412b22..fff4e97 100644 --- a/index.ts +++ b/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`) -}) \ No newline at end of file -- cgit v1.2.3