講師:堇姬 @ Izcc-ctf
2023.10.6
成電二年級/幽夜工作室繪師/台灣好厲駭學員
DC : naup_sumire_hime
IG : ckcsc36th_naup
涉獵C++、C、python、遊戲(tkinter、pygame)、資安(Web、Crypto)、AI、flask、html/css/js、 PHP、DC bot。
喜歡看輕小說、動畫、Vtuber、打音遊,也喜歡看百合,就是一個長年混跡ACG的宅女。
夢想是可以成為很電的駭客跟繪師,也想自己寫出一個AI老婆。
9/22
10/20 python
10/27 linux
11/3 -
11/10 |
11/17 |
|WEB
12/1 |
12/8 -
12/15 -
12/22 | CRYPTO
12/29 -
a=1
while a<12:
print(a)
a+=1
1
2
3
4
5
6
7
8
9
10
11
while True:
print("I LOVE LOLI")
I LOVE LOLI
I LOVE LOLI
I LOVE LOLI
I LOVE LOLI
I LOVE LOLI
I LOVE LOLI
I LOVE LOLI
I LOVE LOLI
I LOVE LOLI
...
for 變數 in 容器:
要執行的函式
d=[0, 1, 2, 3, 4, 5]
for i in d:
print(i)
0
1
2
3
4
5
range(起始值, 終止值, 遞增(減)值)
可以創建一個列表
range(10):0,1,2,3,4,5,6,7,8,9
range(1, 11):1,2,3,4,5,6,7,8,9,10
range(0, 10, 2):0,2,4,6,8
for i in range(5):
print(i)
0
1
2
3
4
是由一堆元素所組成的資料結構
可排序、可修改、可重複
可排序、不可修改、可重複
不可排序、可修改、不可重複
不可排序、無索引、不可重複
a=['水銀燈', '真紅' ] #List
b=('八六', '右田日日姬', 123) #Tuple
c={1:'一月', 2:'二月', 3:'三月'} #Dictionary
d={'常陸茉子', '朝武芳乃',"叢雨", 123, 123} #Set
print(a[1])
print(b[2])
print(c[3])
for i in d:
print(i)
abc
輸入(input)
輸出(output)
函式
def abc(a):
return a+1
print(abc(2))
輸出3
函式名字
參數
回傳
呼叫函式
try:
a = input('輸入數字:')
print(a + 1)
except:
print('發生錯誤')
print('hello')
a = b'Hello, world!'
b = bytes([65, 66, 67, 68, 69])
c = "Hello, world!".encode()
print(type(a),type(b),type(c))
a=b'ABCDE'
print(a[1])
a=bytearray(b"aaaa")
a[1]=67
print(a)
a="bbaabbb"
print(a.strip("b"))
a="abaaabh"
print(a.split("b"))
def a(b,c):
return b+c
print(eval("1+a(1,2)"))
對指定序列做映射
def f(x):
return x**2
print(list(map(f,[1,2,3,4,5])))
def f(x):
return x**2
print(list(map(str,[1,2,3,4,5])))
a="abaaabh"
print(a.encode())
a=b"abaaabh"
print(a.decode())
pow(x,y)
pow(x,y,z)
print(hex(2))
pip install pycryptodome
from Crypto.Util.number import *
from Crypto.Util.number import *
print(bytes_to_long(b"1"))
from Crypto.Util.number import *
print(long_to_bytes(49))
8 & 29 = 8
8 (Decimal) = 01000 (Binary)
29 (Decimal) = 11101 (Binary)
01000 & 11101 = 01000 -> 8
print(8 & 29)
8 | 29 = 8
8 (Decimal) = 01000 (Binary)
29 (Decimal) = 11101 (Binary)
01000 | 11101 = 11101 -> 29
print(8 | 29)
8 ^ 29 = 8
8 (Decimal) = 01000 (Binary)
29 (Decimal) = 11101 (Binary)
01000 ^ 11101 = 10101 -> 21
print(8 ^ 29)
p ^ q = q ^ p
p ^ q ^ n = p ^ ( q ^ n )
p ^ 0 = p
p ^ p = 0
p ^ p ^ q = q
number = 1
print(number)
print(number << 1)
print(number << 2)
print(number << 3)
00000001 → 1
00000010 → 2
00000100 → 4
00001000 → 8
a = 60 # 60 = 0011 1100
c = a >> 2; # 15 = 0000 1111
print(c)
pip install pwntools
from pwn import *
r=remote("ckcsc.net",20000)
r.interactive()
r.recv(n) : 接收 n 個 bytes
r.recvuntil(payload) : 接收到 payload 為止
r.recvline() : 接收一行(到換行為止)
r.recvlines(n) : 接收 n 行
from pwn import *
r=remote("lab.scist.org", 33340)
r.interactive()
或是使用pwntools連上lab.scist.org 33340
from pwn import *
r=remote("lab.scist.org", 33342)
r.recvlines(3)
for i in range(1,101):
n=r.recvline(1)
print(n)
r.sendline(str(i))
r.interactive()
要從1輸入到100
from pwn import *
r=remote("lab.scist.org", 33341)
r.recvlines(8)
f=r.recvline().strip().split(b":")[1]
m=sorted(list(map(int,f.split())))
nth=int(r.recvline().strip().split(b":")[1])
r.sendlineafter(b"answer >",str(m[len(m)-nth]).encode())
r.interactive()
暴力查找會太久所以要使用二分搜來找到答案
from pwn import *
r=remote("lab.scist.org",33343)
left=0
right=1073741824
r.recvlines(2)
while True:
mid= (left+right)//2
r.sendlineafter(b'guess >',str(mid).encode())
ans=r.recvline().strip()
print(ans)
if ans==b"Too small !":
left=mid
elif ans==b"Too big !":
right=mid
else:
break
r.interactive()
solve.py
from pwn import *
r=remote("lab.scist.org", 33344)
r.recvlines(3)
for i in range(100):
Qu=r.recvline()
print(Qu)
c=r.recvline().strip().split()
num1=int(c[0].decode())
num2=int(c[2].decode())
num3=int(c[4].decode())
if num1+num2==num3:
r.sendlineafter(b"which operator (+/-/*) ?",b"+")
elif num1-num2==num3:
r.sendlineafter(b"which operator (+/-/*) ?",b"-")
else:
r.sendlineafter(b"which operator (+/-/*) ?",b"*")
r.interactive()
solve.py