新一代爬虫工具katana

电子说

1.2w人已加入

描述

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

  • 标准和无外设模式支持

  • JavaScript 解析/爬网

  • 可定制的自动表单填写

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

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

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

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

0x01 工具安装

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

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

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

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
go install github.com/projectdiscovery/katana/cmd/katana@latest

0x02 工具使用

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

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

katana -u https://tesla.com

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

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

文件输入:

$ cat url_list.txt


https://tesla.com
https://google.com
katana -list url_list.txt

管道输入:

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

运行实例:

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/

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

无沙盒模式:

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

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

无运行头模式:

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

katana -u https://tesla.com -headless -no-incognito
工具下载:
https://github.com/projectdiscovery/katana
 

审核编辑 :李倩
打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分