7.15学习回顾

7.15学习回顾

七月 15, 2021

字典排序——快速计算

先抓包,注意post需要信息

二话不说上代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#encoding=utf-8
import requests
no=requests.session()
zo=no.get('http://ctf.err0r.top:60002/')
print(zo.text)
ro=zo.text
ro=ro.split('b>')
#print(r)
#print(r[1])
ao=ro[1]
ao=ao.lstrip()
#删除句首指定字符,默认删除
ao=ao.rstrip(' =</')
ao=ao.rstrip('')
dic={}
a=0

for ascii in range(65,123) :
#print(chr(ascii))
for i in ao:
if i==chr(ascii):
a=a+1
if a!=0:
dic.setdefault(chr(ascii), a)
a=0
list = sorted(dic.items(), key = lambda kv:(kv[1], kv[0]),reverse=True)
print(list)
dict=sorted(dic.items(), key = lambda kv:(kv[0]))
#print(type(dict))
#print(str(dict.keys()))
#mystr=str(dict1)
#print(dic)
string = ''
for i in dict:
print(i[0])
string += i[0]
print(string)
'''
print(ao)
ao=eval(ao)
print(ao)
'''
miao={
"result":string,
"submit": "%E6%8F%90%E4%BA%A4"
}
mo=no.post("http://ctf.err0r.top:60002/",data=miao)
print(mo.text)

大体思路通过ascii 将字母循环,将字符串遍历, 并将相应字幕出现的次数写入字典

循环遍历字符串的代码

(只有字符串中有该字符才将其写入字典)

1
2
3
4
5
6
7
8
for ascii in range(65,123) :
#print(chr(ascii))
for i in ao:
if i==chr(ascii):
a=a+1
if a!=0:
dic.setdefault(chr(ascii), a)
a=0

写入字典的代码

1
dic.setdefault(chr(ascii), a)

字典排序代码

!dic.items() ——- dic 为字典名称

1
sorted(dic.items(), key = lambda kv:(kv[1], kv[0]),reverse=True)

reverse=True 控制由大致小 false 反之

注意排序后返回值为 list dict()强制转换即可保留字典特质

换源

16ubuntu 换源

1.备份原始源文件 source.list

1
sudo  cp   /etc/apt/sources.list   /etc/apt/sources.list.bak

2.修改源文件sources.list

(1)更改文件权限使其可编辑

1
sudo  chmod  777  /etc/apt/sources.list

(2)打开文件进行编辑

1
sudo  gedit   /etc/apt/sources.list

(3)删除文件内容,复制链接并且保存

阿里

1
2
3
4
5
6
7
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse

清华

1
2
3
4
5
6
7
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse

3.更新源

更新软件列表,换源完成。

1
sudo apt update