id: privesc-lftp

info:
  name: lftp - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    lftp is a command-line file transfer program for Unix-like systems. It supports various protocols such as FTP, HTTP, SFTP, and FISH, and provides a range of features for file transfer and mirroring. lftp is known for its reliability and scriptability, making it a popular choice for automated file transfer tasks.
  reference:
    - https://gtfobins.github.io/gtfobins/lftp/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,lftp,privesc,local

self-contained: true
code:
  - engine:
      - sh
      - bash
    source: |
      whoami

  - engine:
      - sh
      - bash
    source: |
      lftp -c '!whoami'

  - engine:
      - sh
      - bash
    source: |
      sudo lftp -c '!whoami'

    matchers-condition: and
    matchers:
      - type: word
        part: code_1_response
        words:
          - "root"
        negative: true

      - type: dsl
        dsl:
          - 'contains(code_2_response, "root")'
          - 'contains(code_3_response, "root")'
        condition: or
# digest: 490a0046304402201810370fbdbb3958a0c2e5ee9d7d28d1109cfc1173f09156ab1cd51d34b1ae1c02201ee746ac8849197f3309e3200fd0ceaa344c2aec04366f38c6cf064b0da085f0:922c64590222798bb761d5b6d8e72950