Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
updt
Browse files Browse the repository at this point in the history
  • Loading branch information
nesterenko committed Oct 4, 2023
1 parent 6810042 commit 277d956
Show file tree
Hide file tree
Showing 13 changed files with 545 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lab1-web/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>Чернышова Марина, N33501</title>

</head>
<body>
<h1>Мой прекрасный сайт</h1>
<h3>
<font color="blue">Текст можно скопировать только при вводе пароля. Если пароль не введете - скопировать текст не сможете, даже не пытайтесь, это опасно для жизни.</font>
</h3>
<p>Сможете ли вы скопировать текст?..</p>
<p><img src="marina.jpg" width="450" height="400"></p>
<p>Чтобы разблокировать функционал, назовите имя человека с фотографии: <input type="password" id="password"></p>
<button id="check">Готово</button>

<script type="text/javascript" src="main.js"></script>
</table>
</form>

</body>
</html>
75 changes: 75 additions & 0 deletions lab1-web/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const ifFalseSave = (event) => {
if (event.keyCode == 83) {
event.preventDefault();
return false;
}
}

const ifFalsePrntScrn = (event) => {
if (event.keyCode == 44) {
stopPrntScr();
}
}


function stopPrntScr() {
var inpFld = document.createElement("input");
inpFld.setAttribute("value", ".");
inpFld.setAttribute("width", "0");
inpFld.style.height = "0px";
inpFld.style.width = "0px";
inpFld.style.border = "0px";
document.body.appendChild(inpFld);
inpFld.select();
document.execCommand("copy");
inpFld.remove(inpFld);
}


function main_part(cond) {

document.ondragstart = () => cond;
document.onselectstart = () => cond;
document.oncontextmenu = () => cond;

if (!cond) {

document.addEventListener('keydown', ifFalseSave);
document.addEventListener('keyup', ifFalsePrntScrn);
} else {

document.removeEventListener('keydown', ifFalseSave);
document.removeEventListener('keyup', ifFalsePrntScrn);
}
}

main_part(false);

document.getElementById("check").onclick = () => {
const hashed_passwd = "1076595487";
const passwd = document.getElementById("password").value;
if (passwd.length == 0) alert("Пароль не введен. А зря.");
let x = func(passwd)
if (x == hashed_passwd) {
alert("Пароль введен. Это хорошо.");
main_part(true);
}
else {
alert("Пароль неверный. Доступ я не дам.");
main_part(false);
}
}

function func(string) {

var hash = 0;

if (string.length == 0) return hash;
for (i = 0 ;i<string.length ; i++)
{
ch = string.charCodeAt(i);
hash = ((hash << 5) - hash) + ch;
hash = hash & hash;
}
return hash;
}
Binary file added lab1/~$doc.docx
Binary file not shown.
11 changes: 11 additions & 0 deletions lab2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Лаба 2

### ВСЕ ПОЛЯ С ПУТЯМИ К ФАЙЛАМ ПЕРЕИМЕНУЙТЕ НА СВОИ! ###

### installer.py ###

Инсталлятор

### YourName.py ###

Основной скрипт
54 changes: 54 additions & 0 deletions lab2/YourName.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import os
import time
import shutil

with open('/home/worker/Documents/NameData/log.txt', 'r') as f:

for i in f:
count = i

count = int(count)
if count > 5:
print('Sorry, you need to buy full version of program...')
print('Input y or n!')
answer = input()

if answer == 'y':
print('Price is 1 BTC!')
exit(0)

if answer == 'n':
print('Uninstalling...')
time.sleep(5)
pwd = os.getcwd()
shutil.rmtree(pwd)
exit(0)

else:
print('Incorrect input...')
else:
count += 1
to_wrie = str(count)
with open('/home/worker/Documents/NameData/log.txt', 'w') as f:
f.write(to_wrie)


print('Hello! Whats your name?')

name = input()

names = []


with open('/home/worker/Documents/NameData/naming.txt', 'r') as f:
for i in f:
i = i.replace('\n', '')
names.append(i)

if name in names:
print(f'Hello, my dear {name}, glad to see You again...')

else:
f = open('/home/worker/Documents/NameData/naming.txt', 'a')
f.write(name + '\n')
print(f'Hi, {name}! My name is program!')
38 changes: 38 additions & 0 deletions lab2/installer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import os.path


def start_the_installation(file, filename, data):
need_path = f'{file}/{filename}'
if os.path.isfile(need_path):
pass
else:
need_data = open(need_path, 'w')
need_data.write(data)


print("Start the installation!")

pwd = os.getcwd()
pwl = '/home/worker/Documents'
name_service = 'NameData'
name_main = 'YourAwesomeName!'

path_service = os.path.join(pwl, name_service)
path_main = os.path.join(pwd, name_main)

os.mkdir(path_main)

try:
os.mkdir(path_service)

except:
FileExistsError

with open("source.txt") as f:
data = f.read()

print(data)
start_the_installation(path_service, 'log.txt', '0')
start_the_installation(path_service, 'naming.txt', '')
start_the_installation(path_main, 'YourName.py', data
6 changes: 6 additions & 0 deletions lab3-web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# TIMP-2022

Для запуска меняем токены в app.py, после чего запускаем его, нажимаем на кнопку и радуемся.

Если вы хотите захостить ресурс для общего доступа или же это требует препод - https://habr.com/ru/post/697620/
По умолчанию порт 5000.
26 changes: 26 additions & 0 deletions lab3-web/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import json
from flask import Flask
from flask import render_template
import telebot

bot = telebot.TeleBot("YOUR TOKEN")
user_id = "YOUR TG ID"
app = Flask(__name__)


@app.route('/')
def index():
return render_template('index.html')


@app.route('/processInfo/<string:info>', methods=['POST'])
def process(info):
info = json.loads(info)
info = info.split(" ")
data = {"Processor": info[0], "OS": info[1]}
bot.send_message(user_id, str(data))
return 'Done'


if __name__ == '__main__':
app.run(debug=True)
40 changes: 40 additions & 0 deletions lab3-web/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!Doctype html>
<html>
<head>
<title>
Awesome site
</title>
</head>
<body>
</body>
<button type="button" onclick="get_all()"> Touch! </button>
<script>
function os(){
var Name = "Unknown OS";
if (navigator.userAgent.indexOf("Win") != -1) Name =
"WindowsOS";
if (navigator.userAgent.indexOf("Mac") != -1) Name =
"MacintoshOs";
if (navigator.userAgent.indexOf("Linux") != -1) Name =
"LinuxOS";
if (navigator.userAgent.indexOf("Android") != -1) Name =
"AndroidOS";
if (navigator.userAgent.indexOf("like Mac") != -1) Name =
"IOS";
return Name;
}
function cpu(){
return navigator.hardwareConcurrency;
}

function get_all() {
var a = cpu()
var b = os()
var info = a + " " + b
console.log(info)
const request = new XMLHttpRequest()
request.open('POST', `/processInfo/${JSON.stringify(info)}`)
request.send()
}
</script>
</html>
13 changes: 13 additions & 0 deletions lab3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# TIMP-2022

# Лаба 3

### ВСЕ ПОЛЯ С ПУТЯМИ К ФАЙЛАМ ПЕРЕИМЕНУЙТЕ НА СВОИ! ###

### installer.py ###

Инсталлятор, можно сделать экзешник через pyinstaller

### Secure.py ###

Основной скрипт
Loading

0 comments on commit 277d956

Please sign in to comment.