• 新一代爬虫工具 katana 配置及使用


    新一代爬虫工具 katana 配置及使用。

    在这里插入图片描述

    功能:

    快速且完全可配置的网络爬行

    标准和无外设模式支持

    JavaScript 解析/爬网

    可定制的自动表单填写

    范围控制 - 预配置字段/正则表达式

    可自定义的输出 - 预配置字段

    输入 - 标准输入、URL 和列表

    输出 - 标准输出、文件和 JSON


    0x01 工具安装

    Katana需要Go 1.18才能成功安装。要安装,只需运行以下命令或从发布页面下载预编译的二进制文件。

    go install github.com/projectdiscovery/katana/cmd/katana@latest
    
    • 1

    Docker安装:

    docker pull projectdiscovery/katana:latest
    docker run projectdiscovery/katana:latest -u https://tesla.com
    docker run projectdiscovery/katana:latest -u https://tesla.com -system-chrome -headless
    
    • 1
    • 2
    • 3

    Ubuntu安装:

    
    sudo apt update
    sudo snap refresh
    sudo apt install zip curl wget git
    sudo snap install golang --classic
    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - 
    sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
    sudo apt update 
    sudo apt install google-chrome-stable
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    
    go install github.com/projectdiscovery/katana/cmd/katana@latest
    
    • 1
    • 2

    0x02 工具使用

    Katana需要URL或端点进行爬网,并接受单个或多个输入。

    可以使用 -u 选项提供输入 URL,可以使用逗号分隔的输入提供多个值,同样使用 -list 选项支持文件输入,并且还支持额外的管道输入 (stdin)。

    katana -u https://tesla.com
    
    • 1

    多个 URL 输入(逗号分隔):

    katana -u https://tesla.com,https://google.com
    
    • 1

    文件输入:

    $ cat url_list.txt
    
    https://tesla.com
    https://google.com
    
    • 1
    • 2
    • 3
    • 4
    
    katana -list url_list.txt
    
    • 1
    • 2

    管道输入:

    echo https://tesla.com | katana
    cat domains | httpx | katana
    
    • 1
    • 2

    运行实例:

    
    katana -u https://youtube.com
    
       __        __                
      / /_____ _/ /____ ____  ___ _
     /  '_/ _  / __/ _  / _ \/ _  /
    /_/\_\\_,_/\__/\_,_/_//_/\_,_/ v0.0.1                     
    
          projectdiscovery.io
    
    [WRN] Use with caution. You are responsible for your actions.
    [WRN] Developers assume no liability and are not responsible for any misuse or damage.
    https://www.youtube.com/
    https://www.youtube.com/about/
    https://www.youtube.com/about/press/
    https://www.youtube.com/about/copyright/
    https://www.youtube.com/t/contact_us/
    https://www.youtube.com/creators/
    https://www.youtube.com/ads/
    https://www.youtube.com/t/terms
    https://www.youtube.com/t/privacy
    https://www.youtube.com/about/policies/
    https://www.youtube.com/howyoutubeworks?utm_campaign=ytgen&utm_source=ythp&utm_medium=LeftNav&utm_content=txt&u=https%3A%2F%2Fwww.youtube.com%2Fhowyoutubeworks%3Futm_source%3Dythp%26utm_medium%3DLeftNav%26utm_campaign%3Dytgen
    https://www.youtube.com/new
    https://m.youtube.com/
    https://www.youtube.com/s/desktop/4965577f/jsbin/desktop_polymer.vflset/desktop_polymer.js
    https://www.youtube.com/s/desktop/4965577f/cssbin/www-main-desktop-home-page-skeleton.css
    https://www.youtube.com/s/desktop/4965577f/cssbin/www-onepick.css
    https://www.youtube.com/s/_/ytmainappweb/_/ss/k=ytmainappweb.kevlar_base.0Zo5FUcPkCg.L.B1.O/am=gAE/d=0/rs=AGKMywG5nh5Qp-BGPbOaI1evhF5BVGRZGA
    https://www.youtube.com/opensearch?locale=en_GB
    https://www.youtube.com/manifest.webmanifest
    https://www.youtube.com/s/desktop/4965577f/cssbin/www-main-desktop-watch-page-skeleton.css
    https://www.youtube.com/s/desktop/4965577f/jsbin/web-animations-next-lite.min.vflset/web-animations-next-lite.min.js
    https://www.youtube.com/s/desktop/4965577f/jsbin/custom-elements-es5-adapter.vflset/custom-elements-es5-adapter.js
    https://www.youtube.com/s/desktop/4965577f/jsbin/webcomponents-sd.vflset/webcomponents-sd.js
    https://www.youtube.com/s/desktop/4965577f/jsbin/intersection-observer.min.vflset/intersection-observer.min.js
    https://www.youtube.com/s/desktop/4965577f/jsbin/scheduler.vflset/scheduler.js
    https://www.youtube.com/s/desktop/4965577f/jsbin/www-i18n-constants-en_GB.vflset/www-i18n-constants.js
    https://www.youtube.com/s/desktop/4965577f/jsbin/www-tampering.vflset/www-tampering.js
    https://www.youtube.com/s/desktop/4965577f/jsbin/spf.vflset/spf.js
    https://www.youtube.com/s/desktop/4965577f/jsbin/network.vflset/network.js
    https://www.youtube.com/howyoutubeworks/
    https://www.youtube.com/trends/
    https://www.youtube.com/jobs/
    https://www.youtube.com/kids/
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45

    0x03 爬虫模式

    标准模式:

    标准爬网模式使用底层的标准 go http 库来处理 HTTP 请求/响应。这种模式要快得多,因为它没有浏览器开销。尽管如此,它仍然按原样分析 HTTP 响应正文,没有任何 javascript 或 DOM 渲染,可能会缺少 dom 渲染后的端点或异步端点调用,这些调用可能发生在复杂的 Web 应用程序中,例如,依赖于特定于浏览器的事件。

    无头模式:

    无头模式挂钩内部无头调用,以直接在浏览器上下文中处理 HTTP 请求/响应。这有两个优点:

    HTTP 指纹(TLS 和用户代理)将客户端完全标识为合法浏览器

    更好的覆盖范围,因为端点是分析标准原始响应的,就像在前面的模式中一样,以及启用了javascript的浏览器渲染的响应。

    无头爬网是可选的,可以使用 -headless 选项启用。

    以下是其他无头 CLI 选项 -

    
    katana -h headless
    
    Flags:
    HEADLESS:
       -hl, -headless                    enable headless hybrid crawling (experimental)
       -sc, -system-chrome               use local installed chrome browser instead of katana installed
       -sb, -show-browser                show the browser on the screen with headless mode
       -ho, -headless-options string[]   start headless chrome with additional options
       -nos, -no-sandbox                 start headless chrome in --no-sandbox mode
       -cdd, -chrome-data-dir string     path to store chrome browser data
       -scp, -system-chrome-path string  use specified chrome browser for headless crawling
       -noi, -no-incognito               start headless chrome without incognito mode
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    无沙盒模式:

    使用无沙盒选项运行无头 chrome 浏览器,在以 root 用户身份运行时很有用。

    katana -u https://tesla.com -headless -no-sandbox
    
    • 1

    无运行头模式:

    在没有隐身模式的情况下运行无头 chrome 浏览器,这在使用本地浏览器时很有用。

    katana -u https://tesla.com -headless -no-incognito
    
    • 1
  • 相关阅读:
    【pen200-lab】10.11.1.13
    Linux下的静态链接库和动态链接库
    从基础入门到学穿C++
    cmd命令行查看mysql数据库命令
    Gson简介
    端口安全、MAC地址漂移、MACsec、流量控制、DHCP snooping
    上线flask记录
    全面理解使用Pod
    【day12】二进制插入&查找组成一个偶数最接近的两个素数
    CentOS安装OpenNebula(二)
  • 原文地址:https://blog.csdn.net/u014374009/article/details/132939332