从零开始学RSA:已知n,e,d求p,q和私钥文件修复

2024-04-10 05:36

本文主要是介绍从零开始学RSA:已知n,e,d求p,q和私钥文件修复,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 (8)已知n,e,d求p,q

一看这个标题你就应该有个觉悟,n一定无法直接分解得到p和q。

题目: 10-存货5

题目给出了两个文件,一个是加密脚本chall.py,一个是加密后输出的内容output.txt。

分析一下加密脚本:

from gmpy2 import invertfrom md5 import md5from secret import p, qe = 65537n = p*qphi = (p-1)*(q-1)d = invert(e, phi)print n, e, dprint "Flag: flag{%s}" %md5(str(p + q)).hexdigest()


 

加密脚本真的是很简单啊,flag就是str(p+q)进行md5运算之后的得到的字符串,从output.txt中可以得到n,e,d。

用Winhex打开output文件提取数据

![image desc](./rsa-pic/rsa-11.png)


 

现在的关键问题就是求出p和q来,google一把梭好像可以找到这种骚操作,当时线上比赛做这个题目的时候真的就是google找到的类似题目,百度啊,可不可以靠谱一点。

解题脚本:

已知n,e,d求p,q

#!/usr/bin/python#coding:utf-8import randomfrom md5 import md5def gcd(a, b):if a < b:a, b = b, awhile b != 0:temp = a % ba = bb = tempreturn adef getpq(n,e,d):p = 1q = 1while p==1 and q==1:k = d * e - 1g = random.randint ( 0 , n )while p==1 and q==1 and k % 2 == 0:k /= 2y = pow(g,k,n)if y!=1 and gcd(y-1,n)>1:p = gcd(y-1,n)q = n/preturn p,qdef main():n = 16352578963372306131642407541567045533766691177138375676491913897592458965544068296813122740126583082006556217616296009516413202833698268845634497478988128850373221853516973259086845725813424850548682503827191121548693288763243619033224322698075987667531863213468223654181658012754897588147027437229269098246969811226129883327598021859724836993626315476699384610680857047403431430525708390695622848315322636785398223207468754197643541958599210127261345770914514670199047435085714403641469016212958361993969304545214061560160267760786482163373784437641808292654489343487613446165542988382687729593384887516272690654309e = 65537d = 9459928379973667430138068528059438139092368625339079253289560577985304435062213121398231875832264894458314629575455553485752685643743266654630829957442008775259776311585654014858165341757547284112061885158006881475740553532826576260839430343960738520822367975528644329172668877696208741007648370045520535298040161675407779239300466681615493892692265542290255408673533853011662134953869432632554008235340864803377610352438146264524770710345273439724107080190182918285547426166561803716644089414078389475072103315432638197578186106576626728869020366214077455194554930725576023274922741115941214789600089166754476449453p,q = getpq(n,e,d)print pprint qprint "Flag: flag{%s}" %md5(str(p + q)).hexdigest()if __name__ == '__main__':main()

 (9)私钥文件修复

题目: 11-Jarvis OJ -Crypto-God Like RSA


 

呵呵,这个题我认了,别的不会的题目起码都能看个大概,这个题绝了,只是知道解题脚本中对应的变量是谁了(哈哈哈),顺带把变量给你们注释了,反正我是写不出来。

这里面涉及到的东西太多了,我觉得绝不单单是Python脚本的问题,什么数学、什么算法的,必须给你安排的明明白白的。So,我把这题作为了一个模板,以后有类似的题目,直接掏出来用,莫非这真是"上帝之手"?

题目给出三个文件,一个是公钥文件pubkey.pem,一个是残损的私钥文件private.corrupted,还有一个是密文文件flag.enc。

首先使用openssl提取公钥信息:

──(holyeyes㉿kali2023)-[~/Misc/RSA/godlikeRSA]└─$ openssl rsa -pubin -in pubkey.pem -text -modulusPublic-Key: (4096 bit)Modulus:00:c0:97:78:53:45:64:84:7d:8c:c4:b4:20:e9:33:58:67:ec:78:3e:6c:f5:f0:5c:a0:3e:ee:dc:25:63:d0:eb:2a:9e:ba:8f:19:52:a2:67:0b:e7:6e:b2:34:b8:6d:50:76:e0:6a:d1:03:cf:77:33:d8:b1:e9:d7:3b:e5:eb:1c:65:0c:25:96:fd:96:20:b9:7a:de:1d:bf:fd:f2:b6:bf:81:3e:3e:47:44:43:98:bf:65:2f:67:7e:27:75:f9:56:47:ba:c4:f0:4e:67:2b:da:e0:1a:77:14:40:29:c1:a8:67:5a:8f:f5:2e:be:8e:82:31:3d:43:26:d4:97:86:29:15:14:a9:69:36:2c:76:ed:b5:90:eb:ec:6f:ce:d5:ca:24:1c:aa:f6:63:f8:06:a2:62:cb:26:74:d3:5b:82:4b:b6:d5:e0:49:32:7b:62:f8:05:c4:f7:0e:86:59:9b:f3:17:25:02:aa:3c:97:78:84:7b:16:fd:1a:f5:67:cf:03:17:97:d0:c6:69:85:f0:8d:fa:ce:ee:68:24:63:06:24:e1:e4:4c:f8:e9:ad:25:c7:e0:c0:15:bb:b4:67:48:90:03:9b:20:7f:0c:17:eb:9d:13:44:ab:ab:08:a5:c3:dc:c1:98:88:c5:ce:4f:5a:87:9b:0b:bf:bd:d7:0e:a9:09:59:81:fa:88:4f:59:60:6b:84:84:ad:d9:c7:25:8c:e8:c0:e8:f7:26:9e:37:95:7c:e1:48:29:0f:51:e7:bd:98:2f:f6:cc:80:e7:f0:32:0b:89:51:92:4e:c2:6d:50:53:2b:3b:77:72:d1:bd:1a:1f:92:d7:12:79:61:61:c5:a4:7e:b3:85:eb:f0:7c:6d:46:03:c5:e6:d5:81:2c:ba:7e:ea:8d:51:7d:63:55:34:2a:b6:d4:dc:31:5a:f1:99:e3:dc:8c:83:0b:a2:2a:d5:3c:41:48:41:54:1a:a9:e8:b6:70:bf:d3:fe:ed:19:17:14:94:13:b3:17:e3:8b:8e:6f:53:ed:e2:44:e8:4a:32:d6:5c:0d:a8:80:f5:fc:02:e9:46:55:d5:a4:d3:e7:c6:30:77:f9:73:e9:44:52:d8:13:9d:5d:bf:9e:fa:3a:b5:96:79:82:5b:cd:19:5c:06:a9:00:96:fd:4c:a4:73:88:1a:ec:3c:11:de:b9:3d:e0:50:00:1e:ac:21:97:a1:96:7d:6b:15:f9:6c:c9:34:7f:70:d7:9d:2d:d1:48:4a:81:71:f8:12:dd:32:ba:64:31:60:08:26:4b:09:22:03:83:90:17:7f:f3:a7:72:57:bf:89:6d:e4:d7:40:24:8b:7b:bd:df:33:c0:ff:30:2e:e8:6c:1dExponent: 65537 (0x10001)Modulus=C09778534564847D8CC4B420E9335867EC783E6CF5F05CA03EEEDC2563D0EB2A9EBA8F1952A2670BE76EB234B86D5076E06AD103CF7733D8B1E9D73BE5EB1C650C2596FD9620B97ADE1DBFFDF2B6BF813E3E47444398BF652F677E2775F95647BAC4F04E672BDAE01A77144029C1A8675A8FF52EBE8E82313D4326D49786291514A969362C76EDB590EBEC6FCED5CA241CAAF663F806A262CB2674D35B824BB6D5E049327B62F805C4F70E86599BF3172502AA3C9778847B16FD1AF567CF031797D0C66985F08DFACEEE6824630624E1E44CF8E9AD25C7E0C015BBB4674890039B207F0C17EB9D1344ABAB08A5C3DCC19888C5CE4F5A879B0BBFBDD70EA9095981FA884F59606B8484ADD9C7258CE8C0E8F7269E37957CE148290F51E7BD982FF6CC80E7F0320B8951924EC26D50532B3B7772D1BD1A1F92D712796161C5A47EB385EBF07C6D4603C5E6D5812CBA7EEA8D517D6355342AB6D4DC315AF199E3DC8C830BA22AD53C414841541AA9E8B670BFD3FEED1917149413B317E38B8E6F53EDE244E84A32D65C0DA880F5FC02E94655D5A4D3E7C63077F973E94452D8139D5DBF9EFA3AB59679825BCD195C06A90096FD4CA473881AEC3C11DEB93DE050001EAC2197A1967D6B15F96CC9347F70D79D2DD1484A8171F812DD32BA64316008264B0922038390177FF3A77257BF896DE4D740248B7BBDDF33C0FF302EE86C1Dwriting RSA key-----BEGIN PUBLIC KEY-----MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwJd4U0VkhH2MxLQg6TNYZ+x4Pmz18FygPu7cJWPQ6yqeuo8ZUqJnC+dusjS4bVB24GrRA893M9ix6dc75escZQwllv2WILl63h2//fK2v4E+PkdEQ5i/ZS9nfid1+VZHusTwTmcr2uAadxRAKcGoZ1qP9S6+joIxPUMm1JeGKRUUqWk2LHbttZDr7G/O1cokHKr2Y/gGomLLJnTTW4JLttXgSTJ7YvgFxPcOhlmb8xclAqo8l3iEexb9GvVnzwMXl9DGaYXwjfrO7mgkYwYk4eRM+OmtJcfgwBW7tGdIkAObIH8MF+udE0Srqwilw9zBmIjFzk9ah5sLv73XDqkJWYH6iE9ZYGuEhK3ZxyWM6MDo9yaeN5V84UgpD1HnvZgv9syA5/AyC4lRkk7CbVBTKzt3ctG9Gh+S1xJ5YWHFpH6zhevwfG1GA8Xm1YEsun7qjVF9Y1U0KrbU3DFa8Znj3IyDC6Iq1TxBSEFUGqnotnC/0/7tGRcUlBOzF+OLjm9T7eJE6Eoy1lwNqID1/ALpRlXVpNPnxjB3+XPpRFLYE51dv576OrWWeYJbzRlcBqkAlv1MpHOIGuw8Ed65PeBQAB6sIZehln1rFflsyTR/cNedLdFISoFx+BLdMrpkMWAIJksJIgODkBd/86dyV7+JbeTXQCSLe73fM8D/MC7obB0CAwEAAQ==-----END PUBLIC KEY-----┌──(holyeyes㉿kali2023)-[~/Misc/RSA/godlikeRSA]└─$

然后将提取到的公钥信息填充到"恢复私钥的脚本fix.py"中,然后运行这个脚本。

私钥文件修复

​github.com/Mr-Aur0ra/RSA/blob/master/(9)%E7%A7%81%E9%92%A5%E6%96%87%E4%BB%B6%E4%BF%AE%E5%A4%8D/godlikeRSA/fix.py

┌──(holyeyes㉿kali2023)-[~/Misc/RSA/godlikeRSA]└─$ python3 exp1.py                              checking 100checking 200checking 300checking 400checking 500checking 600checking 700checking 800checking 900checking 1000checking 1100checking 1200checking 1300checking 1400checking 1500checking 1600checking 1700checking 1800checking 1900checking 2000checking 2100checking 2200checking 2300checking 2400checking 2500checking 2600checking 2700checking 2800checking 2900checking 3000checking 3100checking 3200checking 3300checking 3400checking 3500checking 3600checking 3700checking 3800checking 3900checking 4000checking 4100checking 4200checking 4300checking 4400checking 4500checking 4600checking 4700checking 4800checking 4900checking 5000checking 5100checking 5200checking 5300checking 5400checking 5500checking 5600checking 5700checking 5800checking 5900checking 6000checking 6100checking 6200checking 6300checking 6400checking 6500checking 6600checking 6700checking 6800checking 6900checking 7000checking 7100checking 7200checking 7300checking 7400checking 7500checking 7600checking 7700checking 7800checking 7900checking 8000checking 8100checking 8200checking 8300checking 8400checking 8500checking 8600checking 8700checking 8800checking 8900checking 9000checking 9100checking 9200checking 9300checking 9400checking 9500checking 9600checking 9700checking 9800checking 9900checking 10000checking 10100checking 10200checking 10300checking 10400checking 10500checking 10600checking 10700checking 10800checking 10900checking 11000checking 11100checking 11200checking 11300checking 11400checking 11500checking 11600checking 11700checking 11800checking 11900checking 12000checking 12100checking 12200checking 12300checking 12400checking 12500checking 12600checking 12700checking 12800checking 12900checking 13000checking 13100checking 13200checking 13300checking 13400checking 13500checking 13600checking 13700checking 13800checking 13900checking 14000checking 14100checking 14200checking 14300checking 14400checking 14500checking 14600checking 14700checking 14800checking 14900checking 15000checking 15100checking 15200checking 15300checking 15400checking 15500checking 15600checking 15700K = 15791checking 1000checking 2000checking 3000checking 4000checking 5000checking 6000checking 7000checking 8000checking 9000checking 10000checking 11000checking 12000checking 13000checking 14000checking 15000checking 16000checking 17000checking 18000checking 19000checking 20000checking 21000checking 22000checking 23000checking 24000checking 25000checking 26000checking 27000checking 28000checking 29000checking 30000checking 31000checking 32000checking 33000checking 34000checking 35000checking 36000checking 37000checking 38000checking 39000checking 40000checking 41000checking 42000checking 43000checking 44000checking 45000checking 46000checking 47000checking 48000checking 49000checking 50000checking 51000checking 52000checking 53000Kp = 53712checking 100checking 200checking 300checking 400checking 500checking 600checking 700checking 800checking 900checking 1000checking 1100checking 1200checking 1300checking 1400checking 1500checking 1600checking 1700checking 1800checking 1900checking 2000checking 2100checking 2200checking 2300checking 2400checking 2500checking 2600checking 2700checking 2800checking 2900checking 3000checking 3100checking 3200checking 3300checking 3400checking 3500checking 3600checking 3700checking 3800checking 3900checking 4000checking 4100checking 4200checking 4300checking 4400checking 4500checking 4600checking 4700checking 4800checking 4900checking 5000checking 5100checking 5200checking 5300checking 5400checking 5500checking 5600checking 5700checking 5800checking 5900checking 6000checking 6100checking 6200checking 6300checking 6400checking 6500checking 6600checking 6700checking 6800checking 6900checking 7000checking 7100checking 7200checking 7300checking 7400checking 7500checking 7600checking 7700checking 7800checking 7900checking 8000checking 8100checking 8200checking 8300checking 8400checking 8500checking 8600checking 8700checking 8800checking 8900checking 9000checking 9100checking 9200checking 9300checking 9400checking 9500checking 9600checking 9700checking 9800checking 9900checking 10000checking 10100checking 10200checking 10300checking 10400checking 10500checking 10600checking 10700checking 10800checking 10900checking 11000checking 11100checking 11200checking 11300checking 11400checking 11500checking 11600checking 11700checking 11800checking 11900checking 12000checking 12100checking 12200checking 12300checking 12400checking 12500checking 12600checking 12700checking 12800checking 12900checking 13000checking 13100checking 13200checking 13300checking 13400checking 13500checking 13600checking 13700checking 13800checking 13900checking 14000checking 14100checking 14200checking 14300checking 14400checking 14500checking 14600checking 14700checking 14800checking 14900checking 15000checking 15100checking 15200checking 15300checking 15400checking 15500checking 15600checking 15700checking 15800checking 15900checking 16000checking 16100checking 16200checking 16300checking 16400checking 16500checking 16600checking 16700checking 16800checking 16900checking 17000checking 17100checking 17200checking 17300checking 17400checking 17500checking 17600checking 17700checking 17800checking 17900checking 18000checking 18100checking 18200checking 18300checking 18400checking 18500checking 18600checking 18700checking 18800checking 18900checking 19000checking 19100checking 19200checking 19300checking 19400checking 19500checking 19600checking 19700checking 19800checking 19900checking 20000checking 20100checking 20200checking 20300checking 20400checking 20500checking 20600checking 20700checking 20800checking 20900checking 21000checking 21100checking 21200checking 21300checking 21400checking 21500checking 21600checking 21700checking 21800checking 21900checking 22000checking 22100checking 22200checking 22300checking 22400checking 22500checking 22600checking 22700checking 22800checking 22900checking 23000checking 23100checking 23200checking 23300checking 23400checking 23500checking 23600checking 23700checking 23800checking 23900checking 24000checking 24100checking 24200checking 24300checking 24400checking 24500checking 24600checking 24700checking 24800checking 24900checking 25000checking 25100checking 25200checking 25300checking 25400checking 25500checking 25600checking 25700checking 25800checking 25900checking 26000checking 26100checking 26200checking 26300checking 26400checking 26500checking 26600checking 26700checking 26800checking 26900Kq = 26920pwnedp = 30061432003658510087798871614869318011389940352798147030129806359975911392091235344042288409629143229311060231549478211871643725394470760528211801310601767727834886942210718412087541234398453046895030858579989874035849439867334906873642352112428914855967993998732685221108379784833027771293275558876952608462050146340591449046825135890871650866799299533696175818103240024841274114925018619060818213433528894936128306780366785977567327073724428211445259983614467640785163297734447975723664659822673456683284394386723716344090232882990461174301609971805075768328757325956784604364401827152431260896927633163074694121679q = 26136662545551829820746942051638228325025130519175536694008242208616774469870765684858288042819063837180243501117310278632509413217676559484513481677689042623348188876598901642459170232360966754692434316796014314498263800234390539118817050074978421973817764644287745302885861277447227180288605200894138168586207384484170481511828680117688324729381172912436910052489279406590356734739774635376711681212908417321705094537960645308009611045658947359297373154395500467689532455017647450616447445444254910371922944620114234547655209970657063715028350418518417105772707885648587233103869340985670430269862943630137067052883d = 189314060947745787654498165274830331174557121266906779862419555225211185530603428281572732893609400752227106390673469015633513601478376007980907685218789784684913841408741295031489754782076172169319157484287361680256043362028296440972189429040371100663239858141284465980874067131885490419967590348201189710575833318886977656522342412509705514383478694693754208398422979228753024497378460051423550810294749332024347106310964901579178253736977778221603016185935642494136204931234524722205937195008837883867578968312663507844825332250280433460469722801545785384920549610305670512211052257540691951435317870875619595628937534523394133353929222521584160841354771534449084153424347188585906251861248309552253930838373561942975707303028732726506301413434343525650181088504211290391497726019689042160550200171411457613452966587499555164618905387343295621486012988196484264365061465147262989915838838473704337695423465093089724153892389725410085609729143077814394217461295117827225090618358013844801017475143005461542391824369921894127873221707688828770261365746173721607819236320716542560206858465665216449930570401369383789211423678295673603341013341777685726223028517376052521329317581752900566710098686429294852358239672182937051082392901-----BEGIN RSA PRIVATE KEY-----MIIJKAIBAAKCAgEAwJd4U0VkhH2MxLQg6TNYZ+x4Pmz18FygPu7cJWPQ6yqeuo8ZUqJnC+dusjS4bVB24GrRA893M9ix6dc75escZQwllv2WILl63h2//fK2v4E+PkdEQ5i/ZS9nfid1+VZHusTwTmcr2uAadxRAKcGoZ1qP9S6+joIxPUMm1JeGKRUUqWk2LHbttZDr7G/O1cokHKr2Y/gGomLLJnTTW4JLttXgSTJ7YvgFxPcOhlmb8xclAqo8l3iEexb9GvVnzwMXl9DGaYXwjfrO7mgkYwYk4eRM+OmtJcfgwBW7tGdIkAObIH8MF+udE0Srqwilw9zBmIjFzk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h1iEd7r3cyeN7dL0Un2YM2aK3zde386RCMefsnPbIQPR7ZHU05EccYZSA0NhVr1MdJU5oJzRnyWauElN6nr3Z49MKoTj7cJexynaPKye/wwz2TZN6uqbaWejUCJ1Vb3jVbzERGLQYV/JfClijqG+c+E4hksmUkwrYckO8P9EvKRXROkbiXejTTwQrjaqDk42+CD3WtYKTozpnE3/CCDBkmFFWSBlwJEZpRnylw60Pe/TW66/dBw27PPMm7ORri1cjXCyRWm/3M3N+PtHW9AJtLIbRAoIBABgyTrVuAjXd7qO57px/XHtUXvgXudo7XstJ9DYLE4roLEj8zUYDFS9KmGjANcmBpcgbKagWN9SqDQSfo8WkEoAue74n7+8goDbeh0YQ2y0mDmpP34dBwF79USn3O+2lVI+1HXUTfTxOTmLPo5bSsv38HL2t3Ll6cUCg//M7IAQbpRME3z8gIe0/HNWkZjyRadnBsk1QbEmZ8fBtiEp2LHFjnJLASiU+f38+cqqUFcrGBlNvc/7W0SB2a5rp81XRwBGXEGtt+fYlBCWIuHVEih9qFqnP6VAeL6lKMzIpH1rbIrwFoIpMzyrnAjZGOJZ6bBcbgMFtNLBmJMSlmuSIao8=-----END RSA PRIVATE KEY-----┌──(holyeyes㉿kali2023)-[~/Misc/RSA/godlikeRSA]└─$

接着,将私钥文件修复脚本fix.py恢复出私钥来,存放到文件private.pem中。

这就结束了吗,没有,god不是白叫的。你会发现你根据私钥使用openssl直接解密密文文件解不开,而且直接根据p,q,d,c也无法直接求出m。这里又涉及到了RSA加密的填充模式。

这里使用的是PKCS1_OAEP填充模式,参考链接:

RSA加密填充模式

​www.cnblogs.com/lzl-sml/p/3501447.html

然后,接着运行下面的脚本即可得到flag。

┌──(holyeyes㉿kali2023)-[~/Misc/RSA/godlikeRSA]└─$ openssl rsautl -decrypt -inkey private.pem -keyform PEM -in flag.enc -oaepThe command rsautl was deprecated in version 3.0. Use 'pkeyutl' instead.PCTF{0h_U_r_ju5t_lik3_g0d}

   

这篇关于从零开始学RSA:已知n,e,d求p,q和私钥文件修复的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/890185

相关文章

mss32.dll文件丢失怎么办? 电脑提示mss32.dll丢失的多种修复方法

《mss32.dll文件丢失怎么办?电脑提示mss32.dll丢失的多种修复方法》最近,很多电脑用户可能遇到了mss32.dll文件丢失的问题,导致一些应用程序无法正常启动,那么,如何修复这个问题呢... 在电脑常年累月的使用过程中,偶尔会遇到一些问题令人头疼。像是某个程序尝试运行时,系统突然弹出一个错误提

电脑提示找不到openal32.dll文件怎么办? openal32.dll丢失完美修复方法

《电脑提示找不到openal32.dll文件怎么办?openal32.dll丢失完美修复方法》openal32.dll是一种重要的系统文件,当它丢失时,会给我们的电脑带来很大的困扰,很多人都曾经遇到... 在使用电脑过程中,我们常常会遇到一些.dll文件丢失的问题,而openal32.dll的丢失是其中比较

电脑win32spl.dll文件丢失咋办? win32spl.dll丢失无法连接打印机修复技巧

《电脑win32spl.dll文件丢失咋办?win32spl.dll丢失无法连接打印机修复技巧》电脑突然提示win32spl.dll文件丢失,打印机死活连不上,今天就来给大家详细讲解一下这个问题的解... 不知道大家在使用电脑的时候是否遇到过关于win32spl.dll文件丢失的问题,win32spl.dl

电脑提示msvcp90.dll缺少怎么办? MSVCP90.dll文件丢失的修复方法

《电脑提示msvcp90.dll缺少怎么办?MSVCP90.dll文件丢失的修复方法》今天我想和大家分享的主题是关于在使用软件时遇到的一个问题——msvcp90.dll丢失,相信很多老师在使用电脑时... 在计算机使用过程中,可能会遇到 MSVCP90.dll 丢失的问题。MSVCP90.dll 是 Mic

电脑报错cxcore100.dll丢失怎么办? 多种免费修复缺失的cxcore100.dll文件的技巧

《电脑报错cxcore100.dll丢失怎么办?多种免费修复缺失的cxcore100.dll文件的技巧》你是否也遇到过“由于找不到cxcore100.dll,无法继续执行代码,重新安装程序可能会解... 当电脑报错“cxcore100.dll未找到”时,这通常意味着系统无法找到或加载这编程个必要的动态链接库

mysql8.0无备份通过idb文件恢复数据的方法、idb文件修复和tablespace id不一致处理

《mysql8.0无备份通过idb文件恢复数据的方法、idb文件修复和tablespaceid不一致处理》文章描述了公司服务器断电后数据库故障的过程,作者通过查看错误日志、重新初始化数据目录、恢复备... 周末突然接到一位一年多没联系的妹妹打来电话,“刘哥,快来救救我”,我脑海瞬间冒出妙瓦底,电信火苲马扁.

基于51单片机的自动转向修复系统的设计与实现

文章目录 前言资料获取设计介绍功能介绍设计清单具体实现截图参考文献设计获取 前言 💗博主介绍:✌全网粉丝10W+,CSDN特邀作者、博客专家、CSDN新星计划导师,一名热衷于单片机技术探索与分享的博主、专注于 精通51/STM32/MSP430/AVR等单片机设计 主要对象是咱们电子相关专业的大学生,希望您们都共创辉煌!✌💗 👇🏻 精彩专栏 推荐订阅👇🏻 单片机

生信代码入门:从零开始掌握生物信息学编程技能

少走弯路,高效分析;了解生信云,访问 【生信圆桌x生信专用云服务器】 : www.tebteb.cc 介绍 生物信息学是一个高度跨学科的领域,结合了生物学、计算机科学和统计学。随着高通量测序技术的发展,海量的生物数据需要通过编程来进行处理和分析。因此,掌握生信编程技能,成为每一个生物信息学研究者的必备能力。 生信代码入门,旨在帮助初学者从零开始学习生物信息学中的编程基础。通过学习常用

研究人员在RSA大会上演示利用恶意JPEG图片入侵企业内网

安全研究人员Marcus Murray在正在旧金山举行的RSA大会上公布了一种利用恶意JPEG图片入侵企业网络内部Windows服务器的新方法。  攻击流程及漏洞分析 最近,安全专家兼渗透测试员Marcus Murray发现了一种利用恶意JPEG图片来攻击Windows服务器的新方法,利用该方法还可以在目标网络中进行特权提升。几天前,在旧金山举行的RSA大会上,该Marcus现场展示了攻击流程,

【经验交流】修复系统事件查看器启动不能时出现的4201错误

方法1,取得『%SystemRoot%\LogFiles』文件夹和『%SystemRoot%\System32\wbem』文件夹的权限(包括这两个文件夹的所有子文件夹的权限),简单点说,就是使你当前的帐户拥有这两个文件夹以及它们的子文件夹的绝对控制权限。这是最简单的方法,不少老外说,这样一弄,倒是解决了问题。不过对我的系统,没用; 方法2,以不带网络的安全模式启动,运行命令行,输入“ne