yuasa
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # [Team7] Micro Hardening ログ 資料 https://drive.google.com/file/d/15yWPDKDLx5m-a-ZG67gws9xCJVo2jTB-/view ## 接続情報 踏み台サーバへのログイン ``` $ sudo ssh sshX-Y@ZZZ.ZZZ.ZZZ.ZZZ -L 80:192.168.0.X:80 -L 81:192.168.0.X:81 -L 590Y:192.168.0.X:590Y -L 8080:192.168.0.X:8080 -L 10000:192.168.0.X:10000 -bash-4.2$ hostname stepu.u.local ``` 踏み台サーバから競技サーバへのログイン ``` -bash-4.2$ hostname stepu.u.local -bash-4.2$ ssh userY@192.168.0.X (略) Are you sure you want to continue connecting (yes/no)? yes userY@192.168.0.X's password: [20200518-010314 userY@www ~]$ hostname www.dX.local ``` webサイト http://www.dX.local/ ## h2 対応方針 ・やった作業のメモをとる→HackMD ・作業したら共有する ・監視で異変に気づいたら声を出す ・何をやれば良いかわからなければ声を出す ## h1 (参考)対応優先度 ■対応優先度 ▽高 バックアップ ・データベース ・ECサイト  ・インストールディレクトリ ・ブログサイト  ・インストールディレクトリ  ・設定ファイル ・DNS  ・設定ファイル ・各管理画面へのアクセス制限 監視 ・ショッピングサイトの売上 ▽中 ・FTP 監視 ・ポートの空き状態確認 ・プロセス確認 ・crontab -l   ・アクセスログ  ・apache:  tail -f /var/log/apache2/access.log  もしくは  tail -f /var/log/httpd/access.log ▽低 ・メール ## 1セット目 ### h3役割分担 司令塔:BANZAIさん 設定投入:渋谷、荒木 監視:岩崎、湯浅 ### 作業ログ #### BANZAI 14:20 ECサイトダウン →apache2, nginxのサービス再起動 14:36 ECサイトダウン →apache2, nginxサービス状態確認OK →FWで80向けポートがブロックされていた→ポリシー削除でアクセスできると思われる ▽2回目セット目やること ・wordpress、EC CUBE、mysql, postgreSQLの管理画面アクセス制限 ・データベースのバックアップsudoをつけたがpermission deniedでdumpできず ・/var/www/html, nginx配下のバックアップ →サイトがおかしくなったら、バックアップを入れ替えてサービス再起動 ・不要サービスのダウン:ftp、メール ・不要ユーザの削除 ・192.168.0.103のIPアドレスをバン #### 渋谷 <apacheバックアップ> sudo mkdir /usr/local/bk ~~sudo cp apache2.conf /usr/local/bk~~ cp -rp /etc/apache2/ /usr/local/bk sudo cp -rp /usr/local/bk/apache2/ /etc/ <toorユーザ削除> sudo cat /etc/passwd udo userdel -r toor <uf変更> sudo ufw deny from 192.168.0.103 to any sudo ufw status numbered sudo ufw delete 3 sudo ufw delete 5 sudo ufw reload #### 荒木 DNS backup 14:07 /etc/unbound/* を/user/local/bk/dnsにコピー (mvしてしまったので、cpで元に直しました。) →接続を確認していただき異常なし14:12ごろ Mysql backup 14:14 /etc/mysql/* を/usr/local/bk/myにコピー 以下はコピーできなかった? cp: omitting directory 'conf.d' cp: omitting directory 'mariadb.conf.d' Nginx backup 14:19 /etc/nginx/nginx.conf を指定場所にコピー word-press backup 14:25 /var/www/nginx/wp-config.php を指定場所にコピー apacheのアクセスログをとろうとしている 14:35 システムダウン2かいめ14:36 ログとってくれる湯浅くん14:36 再起動 14:40 adminパスワード変更 初期+G7 14:44 root, test パスワード変更  14:45 怪しいfirewall 3つめと5つめ.... #### 岩崎 #### 湯浅 listenしているポート確認 ``` $ ss -antup | grep tcp ``` apacheサーバのログ ``` $ sudo tail -f /var/log/apache2/access.log ``` 攻撃元IPを特定する 接続元IP 192.168.0.101 192.168.0.102 192.168.0.103 192.168.0.105 192.168.0.106 192.168.0.107 192.168.0.108 192.168.0.110 192.168.0.113 192.168.0.120 ショッピングサイトの検索バーに脆弱性らしきもの http://www.d7.local/shop/html/products/list?category_id=&name=%27 でエラー SQLインジェクション(14:27:53) ``` 192.168.0.103 - - [01/Sep/2022:14:27:53 +0900] "GET /shop/html/products/list?login_email=taro@m.local&login_pass=yamadataro&name=1%27+or+%271%27+%3D+%271%27%3B+update+plg_customer_additional_info+set+question01+%3D+%27taro@m.local%27%2C+question02+%3D+%27yamadataro%27+from+dtb_customer+where+plg_customer_additional_info.customer_id+%3D+dtb_customer.customer_id+and+dtb_customer.email+%3D+%27anpan%40m.local%27%3B+-- HTTP/1.1" 200 11488 "http://www.d7.local/shop/html/products/detail/4" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393" ``` クエリ ``` yamadataro&name=1' or '1' = '1'; update plg_customer_additional_info set question01 = 'taro@m.local', question02 = 'yamadataro' from dtb_customer where plg_customer_additional_info.customer_id = dtb_customer.customer_id and dtb_customer.email = 'anpan@m.local'; -- ``` ## 2セット目 ### h3役割分担 司令塔:渋谷 設定投入:黒木、荒木 監視:岩崎、湯浅 ### 作業ログ #### BANZAI ・バックアップを取得 ・hacked by anonymousと表示されたので、  htmlをまるっと入れ替えたがすぐに表示されてしまった。 →何か変なプロセスが動いている?crontab? #### 渋谷 hackedアノニマスの症状 →ページの改ざん →DBの改ざん →pgのPW変更 やりたいこと プロセス監視 cron監視 #### 荒木 passed変更 15:21 root, admin, ubuntu, user1-10, test 全員Hello07に変更 15:35 www-data Hello07に変更 15:40ごろから /var/www/nginx /var/www/htnlで 怪しいファイルを探す topで怪しい動きを探す #### 岩崎 15:20 192.168.0.103 ban 15:32 hacked.txt www-dataというユーザーに作られる ファイアウォールや/var/www/html、tcpのlisten情報などを確認 次やりたいこと IMAPサーバーの設定を変更する #### 湯浅 phpmyadmin パスワード変更(15:30) admin'@'127.0.0.1:Zv7gB5Jy admin'@'192.168.%.% admin'@'localhost' root'@'127.0.0.1:Zv7gB5Jy root'@'192.168.%.%: root'@'localhost' sshのプロセス確認(15:47) 自分たち以外にもroot権限でssh接続してる人がいる? ``` sudo lsof -i | grep "ssh" ... sshd 6245 root 3u IPv4 8379324 0t0 TCP www.d7.local:ssh->192.168.0.200:42210 (ESTABLISHED) sshd 6247 root 3u IPv4 8379330 0t0 TCP www.d7.local:ssh->192.168.0.200:42212 (ESTABLISHED) sshd 6272 user5 3u IPv4 8379324 0t0 TCP www.d7.local:ssh->192.168.0.200:42210 (ESTABLISHED) sshd 6286 root 3u IPv4 8379398 0t0 TCP www.d7.local:ssh->192.168.0.200:42214 (ESTABLISHED) sshd 6306 user2 3u IPv4 8379330 0t0 TCP www.d7.local:ssh->192.168.0.200:42212 (ESTABLISHED) sshd 6374 user3 3u IPv4 8379398 0t0 TCP www.d7.local:ssh->192.168.0.200:42214 (ESTABLISHED) sshd 11290 root 3u IPv4 8370214 0t0 TCP www.d7.local:ssh->192.168.0.200:42132 (ESTABLISHED) sshd 11314 user1 3u IPv4 8370214 0t0 TCP www.d7.local:ssh->192.168.0.200:42132 (ESTABLISHED) sshd 22484 root 3u IPv4 8484702 0t0 TCP www.d7.local:ssh->192.168.0.200:43340 (ESTABLISHED) sshd 22505 user5 3u IPv4 8484702 0t0 TCP www.d7.local:ssh->192.168.0.200:43340 (ESTABLISHED) sshd 24952 root 3u IPv4 8374140 0t0 TCP www.d7.local:ssh->192.168.0.200:42154 (ESTABLISHED) sshd 24984 user4 3u IPv4 8374140 0t0 TCP www.d7.local:ssh->192.168.0.200:42154 (ESTABLISHED) ``` 15:54 RCEができそうなコンテンツが作成されている PHPコード埋め込みプラグインを使用 ログを見る限りはこれを介した攻撃はやられてなさそう? ![](https://i.imgur.com/zN0aeVl.png) 15:57 www.d7.local.152401が攻撃者なので削除 ![](https://i.imgur.com/PJ73aZY.png) 15:59 wordpressのadminユーザーのパスワード変更 admin:iVFtlCX^0oNzchCrXD#1gMm$ 3セット目やること - phpmyadminのadmin、rootパスワード変更 - wordpressのadminパスワード変更 - nginxのログも見る(`/var/log/nginx/access.log`) ## 3セット目 ### 作業ログ #### BANZAI ECCUBEのPW→admin7 webサービス立ち上げ phpmyadmin PWの変更 #### 渋谷 bkup apache2 html nginx crontab確認 プロセス確認 syslog確認 pgログ確認 #### 荒木 16:50前 posgre 9.5/main/ をバックアップ 16:50 落ちる 16:53 wordpress, eccube 不審なユーザはいない wordpress、ECCUBEで不審なユーザがいないか確認する /var/logのログを確認する #### 岩崎 firewallの設定変更 IMAPサーバーの設定変更 apacheの/etc/apache2/apache2.confの設定いじる(更新せず) #### 湯浅 16:32 wordpressパスワード変更 admin:CVsxH)y9AE63c4nV*fgwDHTl 16:32 ユーザーのパスワード変更 ``` $ sudo passwd [user] ``` root:q5V!e8M) user1-11:q5V!e8M) www-data:q5V!e8M) 16:42 phpmyadminのパスワード変更(Zv7gB5Jy) admin'@'127.0.0.1:Zv7gB5Jy admin'@'192.168.%.% admin'@'localhost' root'@'127.0.0.1:Zv7gB5Jy root'@'192.168.%.%: root'@'localhost' 16:48 怪しい投稿の削除 ![](https://i.imgur.com/zN0aeVl.png) 16:58 XSS攻撃の確認 ![](https://i.imgur.com/hvmRl9j.png) 17:15 ECCUBEのログをやっと発見 ``` $ cat /var/www/html/shop/app/log/site_2022-09-01.log ... [2022-09-01 17:12:36] eccube.INFO: > GET /shop/html/admin/ [] [] [2022-09-01 17:12:36] eccube.INFO: < 200 [] [] [2022-09-01 17:14:27] eccube.INFO: Matched route "admin_homepage". {"route_parameters":{"_controller":"\\Eccube\\Controller\\Admin\\AdminController::index","_route":"admin_homepage"},"request_uri":"http://www.d7.local/shop/html/admin/"} [] [2022-09-01 17:14:27] eccube.INFO: > GET /shop/html/admin/ [] [] [2022-09-01 17:14:27] eccube.INFO: < 200 [] [] ``` ## 振り返り

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully