From 2292ad2ec16c22eead9426bf4d70755864b80fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Thu, 7 Mar 2024 17:12:17 +0100 Subject: studisfri-deleted --- prog/baozveza/dsp | Bin 0 -> 24216 bytes prog/baozveza/dsp.c | 106 ++++++++++++ prog/baozveza/vis | Bin 0 -> 40432 bytes prog/baozveza/vis.c | 165 +++++++++++++++++++ prog/studisfri/makefile | 10 -- prog/studisfri/screenshot.sh | 13 -- prog/studisfri/script.js | 1 - prog/studisfri/studis_account.php | 332 -------------------------------------- prog/studisfri/studisfri | 29 ---- "prog/\305\276/QR-Code-generator" | 2 +- 10 files changed, 272 insertions(+), 386 deletions(-) create mode 100755 prog/baozveza/dsp create mode 100644 prog/baozveza/dsp.c create mode 100755 prog/baozveza/vis create mode 100644 prog/baozveza/vis.c delete mode 100644 prog/studisfri/makefile delete mode 100755 prog/studisfri/screenshot.sh delete mode 100644 prog/studisfri/script.js delete mode 100644 prog/studisfri/studis_account.php delete mode 100644 prog/studisfri/studisfri (limited to 'prog') diff --git a/prog/baozveza/dsp b/prog/baozveza/dsp new file mode 100755 index 0000000..1ecf469 Binary files /dev/null and b/prog/baozveza/dsp differ diff --git a/prog/baozveza/dsp.c b/prog/baozveza/dsp.c new file mode 100644 index 0000000..9b406e1 --- /dev/null +++ b/prog/baozveza/dsp.c @@ -0,0 +1,106 @@ +#include +#include +#include +#include +#include +void fft (double complex * out, const double complex * in, int n, bool inverse, int skip) { // use skip=1 for initial calling. internal parameter for recursion. + if (n == 1) { + out[0] = in[0]; + return; + } + double complex omega = cpow(M_E, -2*M_PI*I/n); // nth root of unity (omega^(n-1)=1) + if (inverse) + omega = conj(omega); + // fprintf(stderr, "omega je %lf+%lfi, n je %d\n", creal(omega), cimag(omega), n); + fft(out, in, n/2, inverse, skip*2); + fft(out+n/2, in+skip, n/2, inverse, skip*2); + for (int i = 0; i < n/2; i++) { + double complex sod = out[i]; + double complex lih = out[n/2+i]; + out[i] = (sod + cpow(omega, i)*lih)/(skip == 1 && inverse ? n : 1); + out[n/2+i] = (sod - cpow(omega, i)*lih)/(skip == 1 && inverse ? n : 1); + } +} +double complex qam (int stopnja /* koren orderja */ , int simbol) { + double x = simbol%stopnja-(stopnja-1.0)/2.0; + double y = simbol/stopnja-(stopnja-1.0)/2.0; + return y*I+x; +} +int qam_symbols (int stopnja) { // how many possible symbols does this qam configuration let you use + return stopnja*stopnja; +} +int ofdm_columns (int vzorcev, int skip /* 1 za 0 razmika */) { + return 1+((vzorcev-1)/skip); +} +void ofdm (double complex * out /* space for vzorcev values */, int vzorcev /* must be power of 2 */, int skip, int stopnja, uint64_t simbol) { + memset(out, 0, sizeof out[0] * vzorcev); + for (int i = 0; i < ofdm_columns(vzorcev, skip); i++) { + out[i*skip] = qam(stopnja, simbol % qam_symbols(stopnja)); + simbol /= qam_symbols(stopnja); + } +} // returns frequency domain, run ifft to get complex time domain, which then has to be moduliran +void moduliraj (double * out, double complex * in, int insize, int faktor) { + for (int i = 0; i < insize*faktor; i++) + out[i] = in[i%insize]*sin(M_PI*2*i/(insize*faktor))+in[i%insize]*cos(M_PI*2*i/(insize*faktor)); +} +#ifdef MODEMTEST +#include +#include +#include +#include +int main (int argc, char ** argv) { + if (argc != 5) + error(1, 0, "%s log_2(vzorcev) ofdm_skip stopnja faktor_modulacije", argv[0]); + int vzorcev = 1 << atoi(argv[1]); + int skip = atoi(argv[2]); + int stopnja = atoi(argv[3]); + int faktor = atoi(argv[4]); + int simbolov = pow(qam_symbols(stopnja), ofdm_columns(vzorcev, skip)); + fprintf(stderr, "s temi nastavitvami je stoplcev %d, vsak nosi %d simbolov, skupaj je torej na voljo %d simbolov\n", ofdm_columns(vzorcev, skip), qam_symbols(stopnja), simbolov); + while (true) + for (int simbol = 0; simbol < simbolov; simbol++) { + double complex frequency[vzorcev]; + double complex time[vzorcev]; + double modulirano[vzorcev*faktor]; + ofdm(frequency, vzorcev, skip, stopnja, simbol); + fft(time, frequency, vzorcev, true, 1); + moduliraj(modulirano, time, vzorcev, faktor); + write(STDOUT_FILENO, modulirano, sizeof modulirano); + } +} +#endif +#ifdef FFTTEST +#include +int main () { + printf("fft test.\n"); + double complex sinusoid[128]; + for (int i = 0; i < 128; i++) { + sinusoid[i] = cpow(M_E, 2*M_PI*I/8*i); + for (int j = 0; j < 16+creal(sinusoid[i])*16; j++) printf("#"); + printf("\n"); + } + double complex freq[128]; + printf("fft:\n"); + fft(freq, sinusoid, 128, false, 1); + for (int i = 0; i < 128; i++) { + for (int j = 0; j < 16+creal(freq[i]); j++) printf("#"); + printf("\n"); + } + printf("ifft:\n"); + fft(sinusoid, freq, 128, true, 1); + for (int i = 0; i < 128; i++) { + for (int j = 0; j < 16+creal(sinusoid[i])*16; j++) printf("#"); + printf("\n"); + } + double complex testdata[] = {1, 2, 3, 4}; + double complex output[4]; + fft(output, testdata, 4, false, 1); + fft(testdata, output, 4, true, 1); + printf("fftd:\n"); + for (int i = 0; i < 4; i++) + printf("%lf+%lfi\n", creal(output[i]), cimag(output[i])); + printf("ifftd:\n"); + for (int i = 0; i < 4; i++) + printf("%lf+%lfi\n", creal(testdata[i]), cimag(testdata[i])); +} +#endif diff --git a/prog/baozveza/vis b/prog/baozveza/vis new file mode 100755 index 0000000..9679415 Binary files /dev/null and b/prog/baozveza/vis differ diff --git a/prog/baozveza/vis.c b/prog/baozveza/vis.c new file mode 100644 index 0000000..02a4e99 --- /dev/null +++ b/prog/baozveza/vis.c @@ -0,0 +1,165 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dsp.c" +#include +#include +#include +enum whattodraw { + whattodraw_abs, + whattodraw_re, + whattodraw_im +}; +int main (int argc, char ** argv) { + if (argc != 3) + error(1, 0, "argv[1] must be set. fft length will then be 2**argv[1]\nargv[2] must be set. peak value will then be argv[2] -- use a floating point."); + double peak = strtod(argv[2], NULL); + Display *dpy = XOpenDisplay(NULL); + assert(dpy); + int blackColor = BlackPixel(dpy, DefaultScreen(dpy)); + int width = 200; + int height = 400; + Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, width, height, 0, blackColor, blackColor); + // We want to get MapNotify events + XSelectInput(dpy, w, StructureNotifyMask | KeyPressMask | ExposureMask | VisibilityChangeMask); + // "Map" the window (that is, make it appear on the screen) + XMapWindow(dpy, w); + // Create a "Graphics Context" + GC gc = XCreateGC(dpy, w, 0, NULL); + // Tell the GC we draw using the white color + XSetForeground(dpy, gc, 0xff0000); + // Wait for the MapNotify event + struct pollfd pollfd[2] = { + { + .fd = XConnectionNumber(dpy), + .events = POLLIN | POLLHUP + }, + { + .fd = STDIN_FILENO, + .events = POLLIN + } + }; + int flags = fcntl(XConnectionNumber(dpy), F_GETFL, 0); + assert(flags != -1); + flags |= O_NONBLOCK; + assert(fcntl(XConnectionNumber(dpy), F_SETFL, flags) == 0); + bool flush = false; + int spectrumheight = 100; + void draw_ui () { + XSetForeground(dpy, gc, 0xff0000); + XDrawLine(dpy, w, gc, 0, spectrumheight+1, width, spectrumheight+1); + } + int capturesize = 1 << atoi(argv[1]); + unsigned received_bytes = 0; + double samples[capturesize]; + enum whattodraw whattodraw = whattodraw_abs; + unsigned block = 0; + while (XPending(dpy) || poll(pollfd, 2, -1) > 0) { + if (pollfd[0].revents & POLLIN || XPending(dpy)) { + while (XPending(dpy)) { + XEvent e; + XNextEvent(dpy, &e); + switch (e.type) { + case ConfigureNotify: + width = e.xconfigure.width; + height = e.xconfigure.height; + break; + case MapNotify: + case Expose: + case VisibilityChangeMask: + draw_ui(); + flush = true; + break; + case DestroyNotify: + goto end; + case KeyPress: + switch (XLookupKeysym(&e.xkey, 0)) { + case XK_Up: + spectrumheight--; + break; + case XK_Down: + spectrumheight++; + break; + case XK_a: + case XK_A: + whattodraw = whattodraw_abs; + break; + case XK_r: + case XK_R: + whattodraw = whattodraw_re; + break; + case XK_i: + case XK_I: + whattodraw = whattodraw_im; + break; + } + draw_ui(); + flush = true; + break; + case MappingNotify: + XRefreshKeyboardMapping(&e.xmapping); + break; + } + } + } + if (pollfd[1].revents & POLLIN) { + int rr = read(STDIN_FILENO, ((void *) samples)+received_bytes, sizeof samples-received_bytes); + if (rr == 0) { // EOF + pollfd[1].events = 0; + continue; + } + if (rr < 0) + error(1, errno, "stdin read"); + received_bytes += rr; + if (received_bytes == capturesize*sizeof(samples[0])) { + double complex complex_samples[capturesize]; + for (int i = 0; i < capturesize; i++) + complex_samples[i] = samples[i]; + double complex spectrum[capturesize]; + fft(spectrum, complex_samples, capturesize, false, 1); + XSetForeground(dpy, gc, blackColor); + XFillRectangle(dpy, w, gc, 0, 0, width, spectrumheight+1); + XSetForeground(dpy, gc, 0x00ff00); + for (int i = 0; i < capturesize; i++) { + double frequency; + switch (whattodraw) { + case whattodraw_abs: + frequency = cabs(spectrum[i]); + break; + case whattodraw_re: + frequency = creal(spectrum[i]); + break; + case whattodraw_im: + frequency = cimag(spectrum[i]); + break; + } + if (frequency > peak) + frequency = peak; + XSetForeground(dpy, gc, 0x00ff00); + XDrawLine(dpy, w, gc, i, spectrumheight, i, spectrumheight-(frequency/peak)*spectrumheight); + XSetForeground(dpy, gc, (frequency/peak)*0x00ff00+(frequency/peak)*0x0000ff); + XDrawPoint(dpy, w, gc, i, spectrumheight+2+block%(height-spectrumheight-2)); + } + int scanner = spectrumheight+2+block%(height-spectrumheight-2); + XSetForeground(dpy, gc, 0xabcdef); + XFillRectangle(dpy, w, gc, 0, scanner+1, capturesize, 3); + flush = true; + received_bytes = 0; + block++; + } + } + if (flush) { + XFlush(dpy); + flush = false; + } + } + end: + XCloseDisplay(dpy); +} + diff --git a/prog/studisfri/makefile b/prog/studisfri/makefile deleted file mode 100644 index d264405..0000000 --- a/prog/studisfri/makefile +++ /dev/null @@ -1,10 +0,0 @@ -default: fetchsrc - -fetchsrc: - sftp s@b <<<"get /etc/nginx/sites/studisfri" - sftp s@b <<<"get studisfri/studis_account.php" - sftp s@b <<<"get studisfri/script.js" - sftp s@b <<<"get studisfri/screenshot.sh" - - -.PHONY: default fetchsrc diff --git a/prog/studisfri/screenshot.sh b/prog/studisfri/screenshot.sh deleted file mode 100755 index 5fdc8a1..0000000 --- a/prog/studisfri/screenshot.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -xe -umask 0077 -p=`rev <<<$0 | cut -d/ -f1 | rev` -t=`mktemp -p "" -d $p.XXX` -librewolf --headless --profile $t --no-remote --new-instance --screenshot $t/screenshot.png $1 -mount | grep "on /proc type proc" | grep hidepid=invisible || echo POZOR! leakal bom ime datoteke v procfs! POPRAVI!!! -h=`sha256sum $t/screenshot.png | cut -d\ -f1` -[ -f ../www/studisfri/$h.png ] && echo datoteka_že_obstaja -mv $t/screenshot.png ../www/studisfri/$h.png -chmod o+r ../www/studisfri/$h.png -echo zgoščena_vrednost $h -rm -r $t diff --git a/prog/studisfri/script.js b/prog/studisfri/script.js deleted file mode 100644 index db25d21..0000000 --- a/prog/studisfri/script.js +++ /dev/null @@ -1 +0,0 @@ -console.log("studisfri hijacker loaded - NOOP"); diff --git a/prog/studisfri/studis_account.php b/prog/studisfri/studis_account.php deleted file mode 100644 index 372001b..0000000 --- a/prog/studisfri/studis_account.php +++ /dev/null @@ -1,332 +0,0 @@ -loadHTML($resp); - foreach (explode(" ", trim($x->getElementsByTagName("address")[0]->nodeValue)) as $niz) - if (strpos($niz, "@") !== false) - $un = trim($niz); - return $un; -} -function studis_get ($cookie) { - $string = ""; - $resp = @file_get_contents("https://studisfri.uni-lj.si/StudentProfil/KontaktniPodatki", false, stream_context_create(["ssl" => ["verify_peer" => false, "verify_peer_name" => false], "http" => ["method" => "GET", "header" => "Cookie: {$cookie}"]])); - if (strpos($resp, "/Account/Logout") === false) - return false; - $un = get_un($resp); - $string .= $resp; - $resp = @file_get_contents("https://studisfri.uni-lj.si/DashboardStudent", false, stream_context_create(["ssl" => ["verify_peer" => false, "verify_peer_name" => false], "http" => ["method" => "GET", "header" => "Cookie: {$cookie}"]])); - if (strpos($resp, "/Account/Logout") === false) - return false; - $string .= $resp; - $resp = @file_get_contents("https://studisfri.uni-lj.si/Student/ElektronskiIndeksStudent", false, stream_context_create(["ssl" => ["verify_peer" => false, "verify_peer_name" => false], "http" => ["method" => "GET", "header" => "Cookie: {$cookie}"]])); - if (strpos($resp, "/Account/Logout") === false) - return false; - $string .= $resp; - if (strpos($un, "@") !== false) { - global $db; - $stmt = $db->prepare("update users set cookies=:cookies where username=:username"); - $stmt->bindParam(":username", $un, PDO::PARAM_STR); - $stmt->bindParam(":cookies", $cookie, PDO::PARAM_STR); - $stmt->execute(); - $stmt->closeCursor(); - $cookies = []; - foreach ($http_response_header as $h) { - if (strtolower(explode(": ", $h)[0]) == "set-cookie") { - $cookie = explode("; ", explode(": ", $h)[1])[0]; - $cookies[] = $cookie; - add_infinite_cookie($cookie); - } else - if (strtolower(explode(": ", $h)[0]) != "location") - header($h); - } - if (sizeof($cookies)) { - $stmt = $db->prepare("update users set cookies=:cookies where username=:username"); - $stmt->bindParam(":username", $un, PDO::PARAM_STR); - $cookies = implode("; ", $cookies); - $stmt->bindParam(":cookies", $cookies, PDO::PARAM_STR); - $stmt->execute(); - $stmt->closeCursor(); - } - } - return ["hash" => hash("sha256", $string, true), "username" => $un]; -} -function add_infinite_cookie ($cookie) { - header("Set-Cookie: $cookie; Path=/; Expires=Fri, 31 Dec 9999 23:59:59 GMT; Secure; HttpOnly", false); -} -function make_login_page ($resp) { - $replace = << - - ▶ Pokaži polje za nalaganje obstoječe seje na - strežnik (za napredne uporabnike) - - -
- -
-
-
- -
- -
-

Uporabniško ime in geslo morate prav tako vnesti. Posebej bodite pazljivi, da je geslo pravnilno vnešeno, saj strežnik njegove pravilnosti ne bo preverjal.

-
- - -