Skip to content

Instantly share code, notes, and snippets.

View spellancer's full-sized avatar

Sarkis Nanyan spellancer

  • Russian Federation
View GitHub Profile
@spellancer
spellancer / gist:9869451
Created March 30, 2014 08:23
lab2 - inf. secure
# -*- coding: utf-8 -*-
# Нанян Саркис АК5-81
# Вариант 11, 5 субъектов 3 объекта
# Функция вывода списка файлов с правами
def sprint(sb,objects,ss=-1):
print "\nСписок файлов для пользователя %s: " % subjects[sb]
si = 0
while si<3:
@spellancer
spellancer / gist:9702246
Created March 22, 2014 06:30
yandex webdav mount script
#!/usr/bin/expect
spawn mount.davfs https://webdav.yandex.ru/RPI /home/sarkisn/webdav/yandex
expect "Username:"
send "[email protected]\r"
expect "Password:"
send "PASSWORD\r"
expect eof
#sudo apt-get install expect
@spellancer
spellancer / gist:9508746
Created March 12, 2014 15:02
connection_test
import urllib2
def internet_on():
try:
response=urllib2.urlopen('http://74.125.228.100',timeout=1)
return True
except urllib2.URLError as err: pass
return False
print internet_on()
@spellancer
spellancer / gist:9461736
Last active August 29, 2015 13:57
Email_alert
import smtplib
import sys
from email.mime.text import MIMEText
def mail(motion,smoke):
me = '[email protected]'
you = ['[email protected]', '[email protected]','[email protected]']
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{ root_url }}/">{{ site.title }}</a>
</div>
@spellancer
spellancer / gist:7511384
Created November 17, 2013 09:46
cgroups
import tarfile, re
cpusage = re.compile ("sys/fs/cgroup/cpuacct/lxc/.*/cpuacct.usage$")
ainput = tarfile.open ("input.tgz","r:gz")
res_value = 0
for i in ainput:
if cpusage.search(i.name)!=None:
l = ainput.extractfile(i.name)
current = int(l.readline())
if (current > res_value):
@spellancer
spellancer / gist:7371670
Created November 8, 2013 14:20
1.py.pki
import subprocess
fout = open("output.txt","w")
s = subprocess.Popen (["openssl","verify","input.txt"], stdout=subprocess.PIPE)
out = s.stdout.read()
if "self signed certificate" in out:
r = 1
else:
r = 0
#!/bin/bash
check=$(openssl verify input.txt| grep "self signed certificate")
if [ -n "$check" ]; then
echo "1"
else
echo "0"
fi
#!/bin/bash
crsa=$(openssl rsa -noout -modulus -in input.txt | openssl md5)
ccer=$(openssl x509 -noout -modulus -in input.txt | openssl md5)
if [ "$crsa" == "$ccer" ]; then
echo "1"
else
echo "0"
fi
import re
fr = open ("access.log", "r")
fw = open ("output.txt","w")
pipv4 = re.compile ("^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9][0-9]|[0-9])((\.25[0-5]|\.2[0-4][0-9]|\.1[0-9][0-9]|\.[0-9][0-9]|\.[0-9]){3}) ")
c = 0
l = fr.readlines()
for i in l: