diff --git a/.idea/deployment.xml b/.idea/deployment.xml index e1510fec23b96237cf10f369e30c428347521a29..46b0c1ffa8e068d4aae598eb0aa8ffa12cdb12ca 100644 --- a/.idea/deployment.xml +++ b/.idea/deployment.xml @@ -2,27 +2,13 @@ - + - - - - - - - - - - - - - - diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Chapter 3 Q1 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Chapter 3 Q1 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..abb4dfa30a83ea72616a60f46d1f97a89afb2cb7 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Chapter 3 Q1 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Chapter 3 Q3 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Chapter 3 Q3 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..aed552ba47330de93e55a3eeb4428ef9b2d87d05 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Chapter 3 Q3 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Q1.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Q1.py" new file mode 100644 index 0000000000000000000000000000000000000000..b89acd77c9d3bbe5dda95c2c3ce6f8ad0a1caa02 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Q1.py" @@ -0,0 +1,3 @@ +result = 1 + 2 +print('''计算1+2的结果 +计算结果为:'''+str(result)) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Q2.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Q2.py" new file mode 100644 index 0000000000000000000000000000000000000000..66538297cf4eb03374926c6fb09f0e7b2b980778 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Q2.py" @@ -0,0 +1,9 @@ +x_rate = 0.65 +total_dollars = 200 +fee = 2 + +total_pounds = (int(total_dollars) - int(fee)) * float(x_rate) + +total_dollars = (float(total_pounds) - int(100)) / float(x_rate) - int(fee) + +print(int(total_dollars)) diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Q3.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Q3.py" new file mode 100644 index 0000000000000000000000000000000000000000..e2c8fb64cd921f120ae76e175acd457716a567c6 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\200\345\244\251\344\275\234\344\270\232/guoqijun/Chapter3/Q3.py" @@ -0,0 +1,11 @@ +import random + +section1 = random.randint(1,255) +section2 = random.randint(1,255) +section3 = random.randint(1,255) +section4 = random.randint(1,255) + +random_ip = str(section1) + '.' + str(section2) + '.' + str(section3) + '.' + str(section4) + +print(random_ip) + diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q1 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q1 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..041d4ca307af1e218104b79ca4f472f009950d14 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q1 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q10 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q10 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..b37d72d2af33de2018bc8a6744867e5b77417749 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q10 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q11 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q11 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..32fbf252eff9566f5fd9f829177eedd025e45064 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q11 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q12 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q12 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..9b9de712ae5cd2dbe84d36cb168df8347d54a033 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q12 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q13 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q13 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..3b1f5b4c92d0bfbe7f17208a27528ed56da38765 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q13 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q3 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q3 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..bade504cbe1ceb24246d4f7230f8b75ab28121f7 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q3 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q4 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q4 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..5156f5e0855a65273ffb4eb7b573649ca00add53 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q4 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q5 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q5 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..37e393d592e1aeaad50b68fc6aa292d49b6c4f91 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q5 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q6 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q6 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..aac2aa75e5fb6eac99447b5785fe4b59fdcce3f4 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q6 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q7 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q7 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..368a1739442e2f81e74c51b262c7d176cb6e0a4e Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q7 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q8 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q8 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..fd1e1c2e6fb241832cabe317eb47e45b13152ba6 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q8 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q9 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q9 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..9b3c871ce6fdc92f40600a63129762b109d4b83f Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Chapter 5 Q9 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q1.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q1.py" new file mode 100644 index 0000000000000000000000000000000000000000..c36ddcf588cbf77aa161fab5ca66de2935c78794 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q1.py" @@ -0,0 +1,5 @@ +performances = ['Ventriloquism','Amazing Acrobatics'] + +performances.append('Snake Charmer') + +print(performances) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q10.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q10.py" new file mode 100644 index 0000000000000000000000000000000000000000..75d399206fe6caf5453943800ee7e2deca9e1866 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q10.py" @@ -0,0 +1,8 @@ +l1 = [4,5,7,1,3,9,0] + +l2 = l1.copy() + +l2.sort() + +for i in range(len(l1)): + print(l1[i],l2[i]) diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q11.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q11.py" new file mode 100644 index 0000000000000000000000000000000000000000..315c1248cfa2367f6f22518ab18c961691a5e133 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q11.py" @@ -0,0 +1,17 @@ +import re + +ifconfig_result = 'eno33554944:flags=4163 mtu 1500\n inet 202.100.1.138 netmask 255.255.255.0 broadcast 202.100.1.255\n inet6 fe80::20c:29ff:fe8d:5cb6 prefixlen 64 scopeid 0x20\n ether 00:0c:29:8d:5c:b6 txqueuelen 1000 (Ethernet)\n RX packets 0 bytes 0 (0.0 B)\n RX errors 0 dropped 0 overruns 0 frame 0\n TX packets 33 bytes 4290 (4.1 KiB)\n TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0\n\n' + +re_findall_result = re.findall('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',ifconfig_result) + +for ip in re_findall_result: + if ip.split('.')[3] == '0': + mask = ip + elif ip.split('.')[3] == '255': + broadcast = ip + else: + ipv4_ip = ip + +print('%15s : %-15s' % ('Network Mask',mask)) +print('%15s : %-15s' % ('Broadcast',broadcast)) +print('%15s : %-15s' % ('IPv4 Addr',ipv4_ip)) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q12.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q12.py" new file mode 100644 index 0000000000000000000000000000000000000000..d8b64cfbb16a0ca7ea2680488d15f7f000a09a0e --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q12.py" @@ -0,0 +1,7 @@ +import re + +ifconfig_result = 'eno33554944:flags=4163 mtu 1500\n inet 202.100.1.138 netmask 255.255.255.0 broadcast 202.100.1.255\n inet6 fe80::20c:29ff:fe8d:5cb6 prefixlen 64 scopeid 0x20\n ether 00:0c:29:8d:5c:b6 txqueuelen 1000 (Ethernet)\n RX packets 0 bytes 0 (0.0 B)\n RX errors 0 dropped 0 overruns 0 frame 0\n TX packets 33 bytes 4290 (4.1 KiB)\n TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0\n\n' + +re_result = re.findall('\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}',ifconfig_result) + +print('MAC地址为:',re_result[0]) diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q13.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q13.py" new file mode 100644 index 0000000000000000000000000000000000000000..467dfeb92ff34c796c46b276e830e23c1d7e3ac2 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q13.py" @@ -0,0 +1,23 @@ +import re + +str = """TCP Student 192.168.189.167:32806 Teacher 137.78.5.128:65247, idle 0:00:00, bytes 74, flags UIO + TCP Student 192.168.189.167:80 Teacher 137.78.5.128:65233, idle 0:00:03, bytes 334516, flags UIO""" + +list = str.split('\n') + +dict = {} + +for x in list: + result = re.match('.*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5}).*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5}).*bytes\s+(\d+).*flags\s+(\w*)\s*',x).groups() + key = result[0], result[1], result[2], result[3] + value = result[4], result[5] + dict[key] = value + +print('\n\n打印字典\n') +print(dict) + +print('\n\n格式化打印输出\n') +for key,value in dict.items(): + print('%10s : %-20s |%10s : %-10s |%10s : %-10s |%10s : %-10s|' % ('src',key[0],'src_p',key[1],'dst',key[2],'dst_p',key[3])) + print('%10s : %-20s |%10s : %-10s' % ('bytes',value[0],'flags',value[1])) + print('='*110) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q2.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q2.py" new file mode 100644 index 0000000000000000000000000000000000000000..3f99460764ae3fd5c16633e0d37e687dae5221c8 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q2.py" @@ -0,0 +1,2 @@ +events.pop(3) + diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q3.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q3.py" new file mode 100644 index 0000000000000000000000000000000000000000..b392e118df8fca9261b7a020ee3b7203fecf7858 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q3.py" @@ -0,0 +1,7 @@ +performances = {'Ventriloquism':'9:00am','Snake Charmer':'12:00pm'} + +performances['Amazing Acrobatics'] = '2:00pm' + +performances['Enchanted Elephants'] = '5:00pm' + +print(performances) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q4.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q4.py" new file mode 100644 index 0000000000000000000000000000000000000000..416f860e25255a30319bbee6784f454d9cac1661 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q4.py" @@ -0,0 +1,6 @@ +performances = {'Ventriloquism':'9:00am','Snake Charmer':'12:00pm','Amazing Acrobatics':'2:00pm','Enchanted Elephants':'5:00pm'} + +performances['Enchanted Elephants'] = '6:00pm' + +print(performances) + diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q5.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q5.py" new file mode 100644 index 0000000000000000000000000000000000000000..8cfc5189bbf177be51174a8b09888a9bdcdc2570 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q5.py" @@ -0,0 +1,5 @@ +performances = {'Ventriloquism':'9:00am','Snake Charmer':'12:00pm','Amazing Acrobatics':'2:00pm','Enchanted Elephants':'5:00pm'} + +del performances['Ventriloquism'] + +print(performances) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q6.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q6.py" new file mode 100644 index 0000000000000000000000000000000000000000..f16e1b912972ad605433efe6515c8b59e2ba9d18 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q6.py" @@ -0,0 +1,4 @@ +list_a = ['python','bison','lion'] +list_b = ['python','lion','bison'] + +print(list_a == list_b) diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q7.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q7.py" new file mode 100644 index 0000000000000000000000000000000000000000..41a8c764d039ec1e8124df9f5a6cbfc032ba03cf --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q7.py" @@ -0,0 +1,4 @@ +dict_a = {'python':'reptile','bison':'mammar','lion':'mammar'} +dict_b = {'python':'reptile','lion':'mammar','bison':'mammar'} + +print(dict_a == dict_b) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q8.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q8.py" new file mode 100644 index 0000000000000000000000000000000000000000..773ba4dd1a6320d2bcebf28ab221b4d817f22eda --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q8.py" @@ -0,0 +1,3 @@ +performances = [['Bearded Lady', 'Tiniest Man', 'Ventriloquist Vinnie'],['Amazing Acrobatics', 'Enchanted Elephants'],['Snake Charmer', 'Amazing Acrobatics']] + +print(performances[0][2]) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q9.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q9.py" new file mode 100644 index 0000000000000000000000000000000000000000..e4798224eab28012691a4891ec139b3482332ce8 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 5/Q9.py" @@ -0,0 +1,3 @@ +performances = {'weekdays':['Bearded Lady','Tiniest Man','Ventriloquist Vinnie'],'saturday':['Amazing Acrobatics','Enchanted Elephants'],'sunday':['Snake Charmer','Amazing Acrobatics']} + +print(performances['weekdays'][2]) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 6/Chapter 6 Q1 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 6/Chapter 6 Q1 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..2ba78a313904f15ca9c94082b27c4a6217765e67 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 6/Chapter 6 Q1 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 6/Q1.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 6/Q1.py" new file mode 100644 index 0000000000000000000000000000000000000000..cf7385b6588cdc8866a2406e8417694d117f5605 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\270\211\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 6/Q1.py" @@ -0,0 +1,35 @@ +import os + +os.mkdir('test') +os.chdir('test') +qytang1 = open('qytang1','w') +qytang1.write('test file\n') +qytang1.write('this is qytang\n') +qytang1.close() +qytang2 = open('qytang2','w') +qytang2.write('test file\n') +qytang2.write('qytang python\n') +qytang2.close() +qytang3 = open('qytang3','w') +qytang3.write('test file\n') +qytang3.write('this is python\n') +qytang3.close() +os.mkdir('qytang4') +os.mkdir('qytang5') + +list1 = [] + +list2 = os.listdir() + +for file in list2: + if os.path.isfile(file): + for line in open(file): + if 'qytang' in line: + list1.append(file) + +print('文件中包含"qytang"关键字的文件为') + +for file in list1: + print('\t',end='') + print(file) +print('\n') diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q1 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q1 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..88c215032ef490908f1029141428be13d9ca1e9d Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q1 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q2 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q2 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..54ca0a485cb197104d4d5534c1fae196a3e35ff8 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q2 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q3 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q3 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..6704c1b88d3fe64ac0605316899fe6b10ce528ac Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q3 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q4 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q4 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..bb50603106cdf946ba4ce4b544c4faadcb5b40eb Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q4 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q5 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q5 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..e44d5be408136621ea75c6aaee904ba354972886 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 Q5 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 re_mac \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 re_mac \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..41d176f34ee3b04d12854042728fdba9ddc77925 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Chapter 4 re_mac \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q1.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q1.py" new file mode 100644 index 0000000000000000000000000000000000000000..fc7ce75050173a1e4f5408e2c21a36331ccacf4d --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q1.py" @@ -0,0 +1,7 @@ +s1 = 'qytang' +s2 = '\'day ' +s3 = '2014-9-28' + +new = s1.upper() + s2 + s3 + +print(new) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q2.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q2.py" new file mode 100644 index 0000000000000000000000000000000000000000..b58341986c9226c156bea0864493e40c273b7fb1 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q2.py" @@ -0,0 +1,5 @@ +word = "scallywag" + +sub_word = word[2:6] + +print(sub_word) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q3.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q3.py" new file mode 100644 index 0000000000000000000000000000000000000000..8f5e5cffea6ccb339a939066b5f006887794856e --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q3.py" @@ -0,0 +1,5 @@ +s = 'Gentleman' + +new = s[1:] + '-' + s[0] + 'y' + +print(new) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q4.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q4.py" new file mode 100644 index 0000000000000000000000000000000000000000..28c9e8a8a470febee2125b9fad01cf71aea9d49f --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q4.py" @@ -0,0 +1,18 @@ +department1 = 'Security' +department2 = 'Python' +depart1_m = 'cq_bomb' +depart2_m = 'qinke' +COURSE_FEES_SEC = 456789.123456 +COURSE_FEES_Python = 1234.3456 + +line1 ='Department1 name:%-10s Manager:%-10s COURSE FEES:%-10.2f %s' % (department1,depart1_m,COURSE_FEES_SEC,'The End!') +line2 ='Department2 name:%-10s Manager:%-10s COURSE FEES:%-10.2f %s' % (department2,depart2_m,COURSE_FEES_Python,'The End!') + +# line1 ='Department1 name:{0:<10} Manager:{1:<10} COURSE FEES:{2:<10.2f} {3}'.format(department1,depart1_m,COURSE_FEES_SEC,'The End!') +# line2 ='Department2 name:{0:<10} Manager:{1:<10} COURSE FEES:{2:<10.2f} {3}'.format(department2,depart2_m,COURSE_FEES_Python,'The End!') + +length = len(line1) +print('='*length) +print(line1) +print(line2) +print('='*length) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q5.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q5.py" new file mode 100644 index 0000000000000000000000000000000000000000..e1b05e54cc9ef08eaf8a4dfe4644e68c59bf3271 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/Q5.py" @@ -0,0 +1,10 @@ +str1 = 'Port-channel1.189 192.168.189.254 YES CONFIG up up ' + +import re + +result = re.match('(\w+\-\w+\.\d+)\s+(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+',str1).groups() + +print('-'*80) +print('%-7s : %s' % ('接口',result[0])) +print('%-7s : %s' % ('IP地址',result[1])) +print('%-7s : %s' % ('状态',result[5])) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/re_mac.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/re_mac.py" new file mode 100644 index 0000000000000000000000000000000000000000..4281f9668aedd8904c6fb221a4d762050132b4b0 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\214\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 4/re_mac.py" @@ -0,0 +1,11 @@ +str1 = '166 54a2.74f7.0326 DYNAMIC Gi1/0/11' + +import re + +result = re.match('(\d+)\s+(\w{4}\.\w{4}\.\w{4})\s+([A-Z]+)\s+(\w+\d\/\d\/\d+)',str1).groups() + +print('-'*80) +print('%-10s : %s' % ('VLAN ID',result[0])) +print('%-10s : %s' % ('MAC ADD',result[1])) +print('%-10s : %s' % ('Type',result[2])) +print('%-10s : %s' % ('Interface',result[3])) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 12/Q1.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 12/Q1.py" new file mode 100644 index 0000000000000000000000000000000000000000..92c800db3f386446a5712eef571ecc41db55a9e6 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 12/Q1.py" @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +# -*- coding=utf-8 -*- + +from scapy_ping_one_new import qytang_ping +from paramiko_ssh import qytang_ssh + + +def ping_and_ssh(ip_list, username, password, cmd): + for ip in ip_list: + ping_result = qytang_ping(ip) + if ping_result[1] == 1: + print(ping_result[0], '可达!') + print('登录', ping_result[0], '执行命令', cmd, '回显结果如下:') + print(qytang_ssh(ping_result[0], username=username, password=password, cmd=cmd)) + else: + print(ping_result[0], '不可达!') + + +if __name__ == '__main__': + ip_list = ['192.168.220.129', '192.168.220.130'] + + username = 'root' + password = 'Cisc0123' + + ping_and_ssh(ip_list, username, password,'ls') diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 12/paramiko_ssh.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 12/paramiko_ssh.py" new file mode 100644 index 0000000000000000000000000000000000000000..4a40ecd48bc0df0f3cbdfff02cb1cf5dd6df8a15 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 12/paramiko_ssh.py" @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +# -*- coding=utf-8 -*- + +import paramiko + + +def qytang_ssh(ip, username, password, port=22, cmd='ls'): + ssh = paramiko.SSHClient() + ssh.load_system_host_keys() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(ip, port=port, username=username, password=password, timeout=5, compress=True) + stdin, stdout, stderr = ssh.exec_command(cmd) + x = stdout.read().decode() + return x + + +if __name__ == '__main__': + print(qytang_ssh('192.168.220.129', 'root', 'Cisc0123')) diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 12/scapy_ping_one_new.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 12/scapy_ping_one_new.py" new file mode 100644 index 0000000000000000000000000000000000000000..a64b040c34aa4916e5a8141ec9405dfbff24807a --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 12/scapy_ping_one_new.py" @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding=utf-8 -*- + +from scapy.all import * + + +def qytang_ping(ip): + ping_pkt = IP(dst=ip) / ICMP() + ping_result = sr1(ping_pkt, timeout=1, verbose=False) + if ping_result: + return ip, 1 + else: + return ip, 0 + + +if __name__ == '__main__': + result = qytang_ping('192.168.220.129') + if result[1]: + print(result[0], '通!') + else: + print(result[0], '不通!') diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 13/Chapter 13 Q1 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 13/Chapter 13 Q1 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..3fa804feb75ba1c24c6bf275bc17e03af0e3bb3e Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 13/Chapter 13 Q1 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 13/Q1.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 13/Q1.py" new file mode 100644 index 0000000000000000000000000000000000000000..79c32ff4c176c1aa049934bd78154e5a1a7dc6d5 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 13/Q1.py" @@ -0,0 +1,32 @@ +from scapy.all import * + +class qyt_ping: + def __init__(self,ip): + self.ip = ip + self.srcip = None + self.length = 100 + self.pkt = IP(dst=self.ip,src=self.srcip)/ICMP() + + def src(self,srcip): + self.srcip = srcip + self.pkt = IP(dst=self.ip,src=self.srcip)/ICMP() + + def size(self,length): + self.length = length + self.pkt = IP(dst=self.ip,src=self.srcip)/ICMP() + + def one(self): + result = sr1(self.pkt,timeout=1,verbose=False) + if result: + print(self.ip,'Reachable') + else: + print(self.ip,'Unreachable') + + def ping(self): + for i in range(5): + result = sr1(self.pkt,timeout=1,verbose=False) + if result: + print('!',end='',flush=True) + else: + print('.',end='',flush=True) + print() \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q1 liunx.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q1 liunx.png" new file mode 100644 index 0000000000000000000000000000000000000000..91b0f868a52b21be15c9d053499d13e3da1189eb Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q1 liunx.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q1 win.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q1 win.png" new file mode 100644 index 0000000000000000000000000000000000000000..3a802d3ba62f0f533bd0a66c61f939ea7d1bd5c7 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q1 win.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q2 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q2 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..124ba11a9d250fd99f107bfaede866958f3a08d5 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q2 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q3 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q3 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..8b1319df2a52ceb8e24c71217769907d62e1e370 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q3 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q5 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q5 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..da2ae795b41aee2eff4d70954ebf85fd988544ef Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Chapter 14 Q5 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q1.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q1.py" new file mode 100644 index 0000000000000000000000000000000000000000..dc51c78d817e8d1b7f9e6ee6098ad7f7316748a3 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q1.py" @@ -0,0 +1,8 @@ +import sys + +if 'win' in sys.platform: + print('this is windows!') +elif 'linux' in sys.platform: + print('this is liunx!') +else: + print('other system') \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q2.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q2.py" new file mode 100644 index 0000000000000000000000000000000000000000..a5d5cd1687b5db9387bd264a7e7b8f23b59ad690 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q2.py" @@ -0,0 +1,7 @@ +import sys + +print(sys.path) + +sys.path.insert(0,'c:\\') + +print(sys.path) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q3.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q3.py" new file mode 100644 index 0000000000000000000000000000000000000000..213bc1daf65efd0ebfd7acf140a3574926686dd1 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q3.py" @@ -0,0 +1,21 @@ + +from scapy.all import * + + +def qytang_ping(ip): + ping_pkt = IP(dst=ip) / ICMP() + ping_result = sr1(ping_pkt, timeout=1, verbose=False) + if ping_result: + return ip,1 + else: + return ip,0 + + +if __name__ == '__main__': + import sys + result = qytang_ping(sys.argv[1]) + + if result[1]: + print(result[0], '通!') + else: + print(result[0], '不通!') diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q4.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q4.py" new file mode 100644 index 0000000000000000000000000000000000000000..2351e9b419558b7f185f2faacd281834b691e5db --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q4.py" @@ -0,0 +1,13 @@ +import datetime + +now = datetime.datetime.now() + +fivedayago = (datetime.datetime.now() - datetime.timedelta(days = 5)) + +otherstyletime = now.strftime('%Y-%m-%d_%H-%M-%S') + +time_file_name = 'save_fivedayago_time_' + otherstyletime + '.txt' + +time_file = open(time_file_name,'w') + +time_file.write(str(fivedayago)) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q5.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q5.py" new file mode 100644 index 0000000000000000000000000000000000000000..7045796d6d9cf111b77ab7250f7a7d7da5ba4028 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\344\272\224\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 14/Q5.py" @@ -0,0 +1,17 @@ +from paramiko_ssh import qytang_ssh + +if __name__ == '__main__': + from argparse import ArgumentParser + + usage = 'python Simple_SSH_Client -i ipaddress -u username -p password -c command' + + parser = ArgumentParser(usage=usage) + + parser.add_argument('-i','--ipaddress',dest='ipaddress',help='SSH Sever',default='192.168.220.129',type=str) + parser.add_argument('-u','--username', dest='username', help='SSH Username', default='root', type=str) + parser.add_argument('-p','--password', dest='password', help='SSH Password', default='Cisc0123', type=str) + parser.add_argument('-c','--command', dest='command', help='Shell Command', default='ls', type=str) + + args = parser.parse_args() + + print(qytang_ssh(args.ipaddress,args.username,args.password,cmd=args.command)) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 16/Chapter 16 Q1 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 16/Chapter 16 Q1 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..91c840763a4f77e33b8e480b990709f7b4bb5bdd Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 16/Chapter 16 Q1 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 16/Q1.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 16/Q1.py" new file mode 100644 index 0000000000000000000000000000000000000000..37c0064c18c1f9441e2967df74aeab3b15ad0f6b --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 16/Q1.py" @@ -0,0 +1,40 @@ +from scapy_ping_one_new import scapy_ping_one +from multiprocessing.pool import ThreadPool +import ipaddress + + +def ping_scan(network): + pool = ThreadPool(processes=150) + net = ipaddress.ip_network(network) + + result_obj_dict = {} + + for ip in net: + result_obj = pool.apply_async(scapy_ping_one, args=(str(ip),)) + result_obj_dict[str(ip)] = result_obj + + pool.close() + pool.join() + + active_ip = [] + + for ip, obj in result_obj_dict.items(): + if obj.get()[1] == 1: + active_ip.append(ip) + + return active_ip + + +if __name__ == '__main__': + import datetime + import pickle + + now = datetime.datetime.now() + otherStyleTime = now.strftime("%Y-%m-%d_%H-%M-%S") + scan_file_name = 'scan_save_pickle_' + otherStyleTime + '.pl' + scan_file = open(scan_file_name, 'wb') + pickle.dump(ping_scan('192.168.2.0/24'), scan_file) + scan_file.close() + scan_file = open(scan_file_name, 'rb') + scan_result_list = pickle.load(scan_file) + print(scan_result_list) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 16/scapy_ping_one_new.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 16/scapy_ping_one_new.py" new file mode 100644 index 0000000000000000000000000000000000000000..484131288c29fc3a5cafc2f32b4e29d3fb026678 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 16/scapy_ping_one_new.py" @@ -0,0 +1,31 @@ +import logging + +logging.getLogger("scapy.runtime").setLevel(logging.ERROR) +from scapy.all import * +from random import randint + + +def scapy_ping_one(host): + id_ip = randint(1, 65535) # 随机产生IP ID位 + id_ping = randint(1, 65535) # 随机产生Ping ID位 + seq_ping = randint(1, 65535) # 随机产生Ping序列号位 + # 构造Ping数据包 + packet = IP(dst=host, ttl=1, id=id_ip) / ICMP(id=id_ping, seq=seq_ping) / b'Welcome to qytang' + ping = sr1(packet, timeout=2, verbose=False) # 获取响应信息,超时为2秒,关闭详细信息 + if ping: # 如果有响应信息 + return host, 1 + else: + return host, 2 + + +if __name__ == '__main__': + result1 = scapy_ping_one('172.16.1.102') + if result1[1] == 1: + print(result1[0], '通!') + elif result1[1] == 2: + print(result1[0], '不通!') + result2 = scapy_ping_one('172.16.1.254') + if result2[1] == 1: + print(result2[0], '通!') + elif result2[1] == 2: + print(result2[0], '不通!') diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 17/Chapter 17 Q1 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 17/Chapter 17 Q1 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..68091ba8f0c780742fbbd28a0c46d3a6076a4128 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 17/Chapter 17 Q1 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 17/Q1.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 17/Q1.py" new file mode 100644 index 0000000000000000000000000000000000000000..605a53b508fcf481d3f7351e09635754797289d9 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\205\255\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 17/Q1.py" @@ -0,0 +1,34 @@ +import paramiko + + +def qytang_ssh(ip, username, password, port=22, cmd='ls'): + try: + ssh = paramiko.SSHClient() + ssh.load_system_host_keys() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(ip, port=port, username=username, password=password, timeout=5, compress=True) + stdin, stdout, stderr = ssh.exec_command(cmd) + x = stdout.read().decode() + return x + + except paramiko.ssh_exception.AuthenticationException as e: + print('认证错误', e) + except Exception as e: + print('%stErrorn %s' % (ip, e)) + + +if __name__ == '__main__': + from argparse import ArgumentParser + + usage = "usage: python Simple_SSH_Client -i ipaddr -u username -p password -c command" + + parser = ArgumentParser(usage=usage) + + parser.add_argument("-i", "--ipaddr", dest="ipaddr", help="SSH Server", default='10.1.1.1', type=str) + parser.add_argument("-u", "--username", dest="username", help="SSH Username", default='root', type=str) + parser.add_argument("-p", "--password", dest="password", help="SSH Password", default='Cisc0123', type=str) + parser.add_argument("-c", "--command", dest="command", help="Shell Command", default='ls', type=str) + + args = parser.parse_args() + + print(qytang_ssh(args.ipaddr, args.username, args.password, cmd=args.command)) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 Q1 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 Q1 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..3744c065d01f5ae2d5981a5ec4db76a1501c3a70 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 Q1 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 Q2 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 Q2 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..f48e0251ff093a0cfca8baef5edf15784ca316d2 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 Q2 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 Q3 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 Q3 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..15b1b847c660e3ab2e09f9b46a459cbcdd2866bc Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 Q3 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 Q4 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 Q4 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..b537bf539f599354768926e857a0f34ef366292d Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 Q4 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 \350\277\220\350\241\214HTTP Server\347\250\213\345\272\217.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 \350\277\220\350\241\214HTTP Server\347\250\213\345\272\217.png" new file mode 100644 index 0000000000000000000000000000000000000000..a9a0237f3fbed605adde92a7db8ad75d64b9e7a1 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Chapter 10 \350\277\220\350\241\214HTTP Server\347\250\213\345\272\217.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q1.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q1.py" new file mode 100644 index 0000000000000000000000000000000000000000..3445e1bdce6bd5a0dabdccd8401180c483680c04 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q1.py" @@ -0,0 +1,4 @@ +word = 'Welcome' + +for i in word: + print(i) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q2.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q2.py" new file mode 100644 index 0000000000000000000000000000000000000000..c8477af4a956017b43cb79cc774b07e025e20bcc --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q2.py" @@ -0,0 +1,4 @@ +performances = {'Ventriloquism':'9:00am','Snake Charmer':'12:00pm','Amazing Acrobatics':'2:00pm','Enchanted Elephants':'5:00pm'} + +for showName,showTime in performances.items(): + print(showName+':'+showTime) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q3.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q3.py" new file mode 100644 index 0000000000000000000000000000000000000000..4d5974e7c14f978f5be7ddf5f8666ccb13d72643 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q3.py" @@ -0,0 +1,10 @@ +import random + +num = random.randint(1,10) + +guess = int(input('Guess a number between 1 and 10\n')) + +while guess != num: + guess = int(input('Guess agagin\n')) +else: + print(input('You Win!')) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q4.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q4.py" new file mode 100644 index 0000000000000000000000000000000000000000..71ca62bb663d99c0c91bdf0aee5460b98592ae0f --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q4.py" @@ -0,0 +1,16 @@ +import os +import time + +while True: + result = os.popen('netstat -tulnp').read() + result_list = result.split('\n') + result_list = result_list[2:-1] + for x in result_list: + if x.split()[3].split(':')[-1] == '80': + print('HTTP (TCP/80) has been opened') + break + else: + print('Wait one second to restart monitoring!') + time.sleep(1) + continue + break \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q5.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q5.py" new file mode 100644 index 0000000000000000000000000000000000000000..650914fb853e5fe6358a44b65ce538b3425dfe48 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 10/Q5.py" @@ -0,0 +1,10 @@ +list1 = ['aaa',111,(4,5),2.01] +list2 = ['bbb',333,111,3.14,(4,5)] + +same_object = [] + +for x in list1: + if x in list2: + same_object.append(x) + +print(same_object) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Chapter 11 Q1 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Chapter 11 Q1 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..66d0cd4ad666b961cd0412db18cac5b20fbf32a5 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Chapter 11 Q1 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Chapter 11 Q2 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Chapter 11 Q2 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..a61c108ac1d3216ed2e833b41cb8aeabf8928d37 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Chapter 11 Q2 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Chapter 11 Q3 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Chapter 11 Q3 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..605e92bac05680b39348c99673d2430173099075 Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Chapter 11 Q3 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Chapter 11 Q4 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Chapter 11 Q4 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..c008be80581e3c506b7be6b5713365382af2d5ae Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Chapter 11 Q4 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Q1.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Q1.py" new file mode 100644 index 0000000000000000000000000000000000000000..7ec961452ec4a348dc0ab1dc2efc594fbc8b7a1c --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Q1.py" @@ -0,0 +1,13 @@ +def five(num): + num = 5 + num += 1 + return num + +print(five(2)) + +def main(num): + num = 1 + five(2) + return num + +print(main(2)) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Q2.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Q2.py" new file mode 100644 index 0000000000000000000000000000000000000000..a38b5dfbe61ea977c5eb4c0b42177435d2580d62 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Q2.py" @@ -0,0 +1,17 @@ +def five(): + global num + num =+ 1 + return num + +five() + +print(num) + +def main(): + global num + num = 1 + return num + +main() + +print(num) \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Q3.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Q3.py" new file mode 100644 index 0000000000000000000000000000000000000000..a3228948e19cbd9b7f00de2a51c90e7e5c4f42c9 --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Q3.py" @@ -0,0 +1,12 @@ + +from scapy.all import * + +def qytang_ping(ip): + ping_pkt = IP(dst=ip) / ICMP() + ping_result = sr1(ping_pkt, timeout=2, verbose=False) + if ping_result: + print(ip+' '+'通!') + else: + print(ip+' '+'不通!') + +qytang_ping('192.168.2.254') \ No newline at end of file diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Q4.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Q4.py" new file mode 100644 index 0000000000000000000000000000000000000000..7c6f17bac086b21a957f071d40936e3300d5ae7e --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 11/Q4.py" @@ -0,0 +1,12 @@ +import paramiko + +def qytang_ssh(ip,username,password,port='22',cmd='ls'): + ssh = paramiko.SSHClient() + ssh.load_system_host_keys() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(ip,port=port,username=username,password=password,timeout=5,compress=True) + stdin,stdout,stderr = ssh.exec_command(cmd) + x = stdout.read().decode() + return x + +print(qytang_ssh('192.168.220.129','root','Cisc0123')) diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 9/Chapter 9 Q1 \347\273\223\346\236\234.png" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 9/Chapter 9 Q1 \347\273\223\346\236\234.png" new file mode 100644 index 0000000000000000000000000000000000000000..6f9369b9e85ae63a2b80e36c239c8715e0b7984b Binary files /dev/null and "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 9/Chapter 9 Q1 \347\273\223\346\236\234.png" differ diff --git "a/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 9/Q1.py" "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 9/Q1.py" new file mode 100644 index 0000000000000000000000000000000000000000..02271ec1394e516d281981e6682744137b30d61a --- /dev/null +++ "b/\350\257\276\345\220\216\344\275\234\344\270\232/\347\254\254\345\233\233\345\244\251\344\275\234\344\270\232/guoqijun/Chapter 9/Q1.py" @@ -0,0 +1,10 @@ +import os + +os.popen('route print').read() + +result = os.popen('route print').read().split('\n') + +str = result[16].split(' ') + +if str[10] == str[20] == '0.0.0.0': + print('网关为:' + str[24])